Re: Binding the enabled attribute of each NSPopUpButtonCell
Re: Binding the enabled attribute of each NSPopUpButtonCell
- Subject: Re: Binding the enabled attribute of each NSPopUpButtonCell
- From: Jerry Krinock <email@hidden>
- Date: Tue, 5 May 2009 21:30:20 -0700
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 (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