Pop-Up Button Menu Items & Binding
Pop-Up Button Menu Items & Binding
- Subject: Pop-Up Button Menu Items & Binding
- From: Nicholas Shanks <email@hidden>
- Date: Sun, 7 Mar 2004 16:19:42 +0000
Hello again.
Sorry if I appear to be blasting the lists recently, but I've run out
of steam on a bunch of things all at once :-)
I have a table view with a column of pop-up button cells. The button
cells get their "content" from an object controller's arrangedObjects,
which returns the following array (accessor method creates NSMenuItems
from an array of NSStrings):
- (NSArray *)options
{
NSMutableArray *items = [NSMutableArray array];
NSEnumerator *enumerator = [options objectEnumerator];
while(NSString *title = [enumerator nextObject])
{
NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title
action:@selector(toggleItem:) keyEquivalent:@""] autorelease];
[item setTarget:self];
[item setState: NSOnState];
[items addObject:item];
}
return items;
}
As you can see, in this test case I'm setting the state of them all to
NSOnState and with an action of toggleItem:
The behaviour I want is for the pop-up menu to have checkmarks next to
each menu item depending on some flag (one day) which toggle the flag
state when the menu item is selected.
The menu exhibits pull-down behaviour and the first item in the list is
the menu title (doesn't matter about state and action for that one).
This does not work. When I run the app the menu items shown are:
<NSMenuItem 0xSOMEADDR> etc.
To get around this, I set the menu's "contentValues" binding to
options.title, and that correctly displays the menu item title, but i
still get no checkmarks.
What am I doing wrong?
- Nick.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.