Document Window Versions Drop-down Menu

  • Hi all,

    I'm writing a document based app. Each document is displayed in a window,
    and can have several other windows too.
    The primary window and the others are the same (same NIB, same window
    controller), each window is able to display a different part of the
    document data.

    At the beginning, only a single window is opened, and the user can request
    other windows to display the document via a menu item.

    So now, when the first window is opened, it has a drop down menu in its
    title bar, to let the user Rename, Duplicate, etc..., the document.

    What happen is if a second window (and subsequent ones) is opened, it
    doesn't have this menu.
    I thought every window would get that menu, after all each one is tied to
    the document.

    More important, if the first opened window (the one with the menu) is
    closed, the menu is just lost. The user user is still able to act on the
    document via the File menu, though.

    So my question is :

    Is there a way to put the menu on other windows too, is there any available
    API to do that ? (I didn't find anything related in the documentation, and
    googling that didn't produce any result)
    Or maybe it is the right behavior, the first window get the menu, and other
    windows are considered "secondary windows" and don't get it ? (the
    documentation refers to my situation as "multiple-view document", and
    suggests that it's right to open several windows for the same document).

    Anybody can provide feedback on that ?

    Thank you for your answers.

    Vince.
  • On May 14, 2013, at 00:07 , Vincent CARLIER <vince.carlier...> wrote:

    > Is there a way to put the menu on other windows too, is there any available
    > API to do that ?

    All document windows should have the menu. My guess is that you forgot to invoke '-[NSDocument addWindowController:]' on the additional window controllers.
  • Hi Quincey,

    thank you for the quick answer.
    Unfortunately, no, I didn't forget to add the window controllers using the
    method you mention.

    At document creation/opening, a first WC is created (I mean alloc/init),
    added to the document, and released.

    As the user request additional windows, the same path is taken, a new WC is
    created, added to the document, and finally receive a showWindow: message,
    that I send to it directly :

    -(IBAction)openDocumentInNewWindow:(id)sender {
        AMDocumentWindowController *dwc = [[AMDocumentWindowController alloc]
    init];
        [[self document] addWindowController:gpdwc];
        [gpdwc release];
        [gpdwc showWindow:self];
    }

    This method is defined in the "primary" WC controller class.

    No matter what I do, only the first window (that is the window managed by
    the first WC created for the document) gets the menu.
    This is true (at least for me ;) even if subsequent WC aren't the same
    class, and windows are totally different.

    I don't know if it makes any difference, I'm running Mac OS X Mountain Lion
    10.8.3, Xcode 4.6.2.

    Vince.

    2013/5/14 Quincey Morris <quinceymorris...>

    > On May 14, 2013, at 00:07 , Vincent CARLIER <vince.carlier...>
    > wrote:
    >
    > Is there a way to put the menu on other windows too, is there any available
    > API to do that ?
    >
    >
    > All document windows should have the menu. My guess is that you forgot to
    > invoke '-[NSDocument addWindowController:]' on the additional window
    > controllers.
    >
    >
  • -(IBAction)openDocumentInNewWindow:(id)sender {
        AMDocumentWindowController *dwc = [[AMDocumentWindowController alloc]
    init];
        [[self document] addWindowController:gpdwc];
        [gpdwc release];
        [gpdwc showWindow:self];
    }

    Typo here, WC reference name is "dwc", not "gpdwc". Sorry.

    2013/5/14 Vincent CARLIER <vince.carlier...>

    > Hi Quincey,
    >
    > thank you for the quick answer.
    > Unfortunately, no, I didn't forget to add the window controllers using the
    > method you mention.
    >
    > At document creation/opening, a first WC is created (I mean alloc/init),
    > added to the document, and released.
    >
    > As the user request additional windows, the same path is taken, a new WC
    > is created, added to the document, and finally receive a showWindow:
    > message, that I send to it directly :
    >
    > -(IBAction)openDocumentInNewWindow:(id)sender {
    > AMDocumentWindowController *dwc = [[AMDocumentWindowController alloc]
    > init];
    > [[self document] addWindowController:gpdwc];
    > [gpdwc release];
    > [gpdwc showWindow:self];
    > }
    >
    > This method is defined in the "primary" WC controller class.
    >
    > No matter what I do, only the first window (that is the window managed by
    > the first WC created for the document) gets the menu.
    > This is true (at least for me ;) even if subsequent WC aren't the same
    > class, and windows are totally different.
    >
    > I don't know if it makes any difference, I'm running Mac OS X Mountain
    > Lion 10.8.3, Xcode 4.6.2.
    >
    > Vince.
    >
    >
    > 2013/5/14 Quincey Morris <quinceymorris...>
    >
    >> On May 14, 2013, at 00:07 , Vincent CARLIER <vince.carlier...>
    >> wrote:
    >>
    >> Is there a way to put the menu on other windows too, is there any
    >> available
    >> API to do that ?
    >>
    >>
    >> All document windows should have the menu. My guess is that you forgot to
    >> invoke '-[NSDocument addWindowController:]' on the additional window
    >> controllers.
    >>
    >>
    >
  • To illustrate the issue, I created a simple test project that you can clone
    from Bitbucket : https://bitbucket.org/vincedev/tesdocapp.git

    As you will see, the menu item opens a second (and any number) of windows
    for the document, but only the first has got the menu.

    Vince.

    2013/5/14 Vincent CARLIER <vince.carlier...>

    > -(IBAction)openDocumentInNewWindow:(id)sender {
    > AMDocumentWindowController *dwc = [[AMDocumentWindowController alloc]
    > init];
    > [[self document] addWindowController:gpdwc];
    > [gpdwc release];
    > [gpdwc showWindow:self];
    > }
    >
    > Typo here, WC reference name is "dwc", not "gpdwc". Sorry.
    >
    >
    > 2013/5/14 Vincent CARLIER <vince.carlier...>
    >
    >> Hi Quincey,
    >>
    >> thank you for the quick answer.
    >> Unfortunately, no, I didn't forget to add the window controllers using
    >> the method you mention.
    >>
    >> At document creation/opening, a first WC is created (I mean alloc/init),
    >> added to the document, and released.
    >>
    >> As the user request additional windows, the same path is taken, a new WC
    >> is created, added to the document, and finally receive a showWindow:
    >> message, that I send to it directly :
    >>
    >> -(IBAction)openDocumentInNewWindow:(id)sender {
    >> AMDocumentWindowController *dwc = [[AMDocumentWindowController alloc]
    >> init];
    >> [[self document] addWindowController:gpdwc];
    >> [gpdwc release];
    >> [gpdwc showWindow:self];
    >> }
    >>
    >> This method is defined in the "primary" WC controller class.
    >>
    >> No matter what I do, only the first window (that is the window managed by
    >> the first WC created for the document) gets the menu.
    >> This is true (at least for me ;) even if subsequent WC aren't the same
    >> class, and windows are totally different.
    >>
    >> I don't know if it makes any difference, I'm running Mac OS X Mountain
    >> Lion 10.8.3, Xcode 4.6.2.
    >>
    >> Vince.
    >>
    >>
    >> 2013/5/14 Quincey Morris <quinceymorris...>
    >>
    >>> On May 14, 2013, at 00:07 , Vincent CARLIER <vince.carlier...>
    >>> wrote:
    >>>
    >>> Is there a way to put the menu on other windows too, is there any
    >>> available
    >>> API to do that ?
    >>>
    >>>
    >>> All document windows should have the menu. My guess is that you forgot
    >>> to invoke '-[NSDocument addWindowController:]' on the additional window
    >>> controllers.
    >>>
    >>>
    >>
    >
  • On May 14, 2013, at 1:33 AM, Vincent CARLIER <vince.carlier...> wrote:

    > No matter what I do, only the first window (that is the window managed by
    > the first WC created for the document) gets the menu.

    What does the secondary window return for -isExcludedFromWindowsMenu? It's possible that NSDocument automatically turns that on for windows owned by secondary window controllers.

    --Kyle Sluder
  • On May 14, 2013, at 04:30 , Vincent CARLIER <vince.carlier...> wrote:

    > As you will see, the menu item opens a second (and any number) of windows for the document, but only the first has got the menu.

    Yes, now you've pointed this out, I can see the same (mis)behavior in my own apps. Whether it used to work and now doesn't, I can't recall.

    But it does look like a bug.
  • Hi Kyle,

    2013/5/14 Kyle Sluder <kyle...>

    > On May 14, 2013, at 1:33 AM, Vincent CARLIER <vince.carlier...>
    > wrote:
    >
    >> No matter what I do, only the first window (that is the window managed by
    >> the first WC created for the document) gets the menu.
    >
    > What does the secondary window return for -isExcludedFromWindowsMenu?

    Windows all answer 'NO' to that message, and of course all window titles
    appear in the menu.

    > It's possible that NSDocument automatically turns that on for windows
    > owned by secondary window controllers.
    >

    NSWindow class reference tells that the default is NO for a window.
    Didn't you confuse "windows menu" with "versions menu" ? I'm really talking
    about the drop down menu, next to the window title.
    I did look for a method called -isExcludedFromVersionsMenu, or something
    like that, and found nothing.

    It seems "Versions" is some kind of opaque feature.

    > --Kyle Sluder

    Vince.
  • Re Quincey,

    2013/5/14 Quincey Morris <quinceymorris...>

    > On May 14, 2013, at 04:30 , Vincent CARLIER <vince.carlier...>
    > wrote:
    >
    > As you will see, the menu item opens a second (and any number) of windows
    > for the document, but only the first has got the menu.
    >
    >
    > Yes, now you've pointed this out, I can see the same (mis)behavior in my
    > own apps. Whether it used to work and now doesn't, I can't recall.
    >
    > But it does look like a bug.
    >
    >
    To me it does too.
    So I did report a bug to Apple (#13896792).

    >
    Vince.
previous month may 2013 next month
MTWTFSS
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    
Go to today