On 2009 May 05, at 20:40, Dave Geering wrote:

It'd be nice if I could somehow hook into whatever is responsible for
making the menu . . .

 - (void) willAddMenuItem:(NSMenuItem *) aMenuItem
 toPopUpButton:(NSPopUpButton *)
 forObject:(id) yourObject
 {
   [aMenuItem setEnabled:[[yourObject valueForKey:@"optionAllowed"]
boolValue]];
 }

But then there would have to be another API to give it the items, and another to localize the titles. Don't wish for that.

Actually, reality is better than your dream. The hard part is to figure out which hook to use. Look at
  -[NSPopUpButtonCell setMenu:]
  -[NSMenu menuNeedsUpdate]

The easy part is to create the menu programatically. You start at the top, creating menu items, and add them to the menu as you go along. As you create each menu item, you set its title, target, action, enabled, representedObject, etc. It's very straightforward coding.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to