• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Main menu in NSDocument based application
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Main menu in NSDocument based application


  • Subject: Re: Main menu in NSDocument based application
  • From: Bruce Cresanta <email@hidden>
  • Date: Mon, 31 Jan 2011 15:51:12 -0700

Thank you,

I needed to know about the responder chain...  The thing is well thought out.

Bruce


On Jan 31, 2011, at 3:43 PM, Sherm Pendley wrote:

> On Mon, Jan 31, 2011 at 5:25 PM, Bruce Cresanta <email@hidden> wrote:
>>
>>        I've been scouring through the docs trying to figure out how to get a reference to the main menu in an NSDocument based app.    I need to make programmatic changes to the menu depending on which NSDocument is key.   Would you please help me find a pointer to the main menu?
>
> What kind of changes? In general, adding and removing menu items is
> discouraged in Mac apps. Disabling menu items that don't apply to the
> current document and/or selection is the preferred approach, and for
> that you don't need a pointer to the menu. The current document is in
> the responder chain, so if it doesn't respond to a menu item's action
> message, that menu item will be disabled automatically. For more
> detailed control, for example to disable a menu item based on the
> current selection in a document, one can write a -validateMenuItem:
> method to decide whether the given menu item should be enabled or not.
>
> I'm not trying to give you the "HIG lecture," I'm just saying -
> depending on what you want to do, there might be an easier way to do
> it that doesn't actually need a pointer to the main menu. On the other
> hand, there are certainly reasons to alter the main menu in other ways
> that *do* require such a pointer. So, if you do need it, there's
> NSApplications's mainMenu method, which you can call using the NSApp
> global, as in:
>
>  NSMenu *menu = [NSApp mainMenu];
>
> sherm--
>
> --
> Cocoa programming in Perl:
> http://camelbones.sourceforge.net

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Main menu in NSDocument based application (From: Bruce Cresanta <email@hidden>)
 >Re: Main menu in NSDocument based application (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: Main menu in NSDocument based application
  • Next by Date: worker thread iterating over array - SLOW
  • Previous by thread: Re: Main menu in NSDocument based application
  • Next by thread: worker thread iterating over array - SLOW
  • Index(es):
    • Date
    • Thread