Converting From Simple to Doc Based App - Problems with Menus

  • Being new to Cocoa I started my project with a Simple Cocoa
    Application template. I have now converted to a Doc Based template by
    adding all my code and adding my  delegates and substituting my window
    in the Document nib. However I have  a problem with some of the menus.
    Most of my menus go to the first responder, however some are linked to
    views on the window itself. However the menu is in the 'MainMenu' nib
    but my window is in the 'MyDocument' nib and therefore can't connect
    the two. I'm not really sure the correct way to hook everything up so
    would appreciate some advice.

    Should I really have the menu in the Document nib? I tried that and
    got some funny extra menus at the beginning of the menubar.
    Should I have my main menu in the doc nib and just a basic one in the
    'MainMenu' nib?

    thanks!

    Peter Zegelin
  • Change the targets for the menu items to be first responder instead of
    the views themselves. The views will still get the actions when they
    are made first responder, which happens automatically.

    Menus in the main menu bar should target either first responder or
    some object that lives in the same nib, possibly the application or
    application's delegate. Don't put menus in the document nib (except
    contextual menus that pertain to a specific view).

    hth,

    G.

    On 1 May 2008, at 3:15 pm, Peter Zegelin wrote:
    > Being new to Cocoa I started my project with a Simple Cocoa
    > Application template. I have now converted to a Doc Based template
    > by adding all my code and adding my  delegates and substituting my
    > window in the Document nib. However I have  a problem with some of
    > the menus. Most of my menus go to the first responder, however some
    > are linked to views on the window itself. However the menu is in the
    > 'MainMenu' nib but my window is in the 'MyDocument' nib and
    > therefore can't connect the two. I'm not really sure the correct way
    > to hook everything up so would appreciate some advice.
    >
    > Should I really have the menu in the Document nib? I tried that and
    > got some funny extra menus at the beginning of the menubar.
    > Should I have my main menu in the doc nib and just a basic one in
    > the 'MainMenu' nib?
    >
    > thanks!
    >
    > Peter Zegelin
  • OK - thanks - that makes sense. Bummer - I had it all set up nicely:-)

    regards,

    Peter

    On 01/05/2008, at 3:48 PM, Graham Cox wrote:

    > Change the targets for the menu items to be first responder instead
    > of the views themselves. The views will still get the actions when
    > they are made first responder, which happens automatically.
    >
    > Menus in the main menu bar should target either first responder or
    > some object that lives in the same nib, possibly the application or
    > application's delegate. Don't put menus in the document nib (except
    > contextual menus that pertain to a specific view).
    >
    > hth,
    >
    > G.
    >
    >
    >
    >
    > On 1 May 2008, at 3:15 pm, Peter Zegelin wrote:
    >> Being new to Cocoa I started my project with a Simple Cocoa
    >> Application template. I have now converted to a Doc Based template
    >> by adding all my code and adding my  delegates and substituting my
    >> window in the Document nib. However I have  a problem with some of
    >> the menus. Most of my menus go to the first responder, however some
    >> are linked to views on the window itself. However the menu is in
    >> the 'MainMenu' nib but my window is in the 'MyDocument' nib and
    >> therefore can't connect the two. I'm not really sure the correct
    >> way to hook everything up so would appreciate some advice.
    >>
    >> Should I really have the menu in the Document nib? I tried that and
    >> got some funny extra menus at the beginning of the menubar.
    >> Should I have my main menu in the doc nib and just a basic one in
    >> the 'MainMenu' nib?
    >>
    >> thanks!
    >>
    >> Peter Zegelin
    >>
previous month may 2008 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