• 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: Application Menu - Preferences
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application Menu - Preferences


  • Subject: Re: Application Menu - Preferences
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 24 Feb 2010 13:39:17 -0800

On Feb 24, 2010, at 12:58, David Blanton wrote:

> What I was really getting at is how to set the target / action for when the item is selected.  Here is what I did,  so if this is way off base please let me know.
>
> I sub-classed NSMenuItem and set the Preferences menu item to this class.
>
> In the awakeFromNib I set the target and action.
>
> Am I doing too much?  Is there a 'less code' approach?

Maybe I'm missing a detail of your requirements, but this seems like the hard way.

Simply set the Preferences menu item target to First Responder (i.e. nil) and its action to a method name of your choosing. Implement that method in your application delegate. The action travels up the responder chain to the application and then finally to the application delegate, where your method will be found.

Your application delegate can then do whatever is necessary to display the preferences (such as creating a window controller the first time, and telling it to display the window).

Note: Paul suggested a slightly different way, connecting the action to something in the NIB file. That works fine too, but the drawback with such an approach is that you have to load up your main menu NIB file with additional windows and views. It seems cleaner to me to put the preferences window in a separate NIB and have the app delegate create the window controller that loads the separate NIB.


_______________________________________________

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

  • Follow-Ups:
    • Re: Application Menu - Preferences
      • From: David Blanton <email@hidden>
References: 
 >Application Menu - Preferences (From: David Blanton <email@hidden>)
 >Re: Application Menu - Preferences (From: Paul Bruneau <email@hidden>)
 >Re: Application Menu - Preferences (From: David Blanton <email@hidden>)

  • Prev by Date: Re: Getting relative day-of-week name?
  • Next by Date: Looking for info on anti-piracy and trial-mode techniques for my app . . .
  • Previous by thread: Re: Application Menu - Preferences
  • Next by thread: Re: Application Menu - Preferences
  • Index(es):
    • Date
    • Thread