programmatically modifying NSPopUpButton's NSMenu
programmatically modifying NSPopUpButton's NSMenu
- Subject: programmatically modifying NSPopUpButton's NSMenu
- From: Chuck Soper <email@hidden>
- Date: Sat, 20 Dec 2003 10:23:19 -0800
Hello,
How do I programmatically add and remove menu items from an
NSPopUpButton at runtime? I've done numerous searches on
cocoa.mamasam, but I wasn't able to find the answer. I did find one
post that said, "This problem has been discussed to death, so please
see the archives."
In IB, I dragged an NSPopUpButton to my window. This window is in a
separate nib file. I added an NSPopUpButton outlet to my controller
and made the connection. I added an action to my controller for
selecting the popup menu and implemented the method.
In awakeFromNib, numberOfItems is always zero yet the menu has two items:
int numberOfItems = [[myPopUpButton menu] numberOfItems];
printf("menu Items = %d\n", numberOfItems);
numberOfItems = [myPopUpButton numberOfItems];
printf("popup Items = %d\n", numberOfItems);
In awakeFromNib, the following code does nothing:
[myPopUpButton removeAllItems];
Or:
[[myPopUpButton menu] removeItemAtIndex:0];
[[myPopUpButton menu] removeItemAtIndex:1];
At runtime, my popup menu has two items and I have confirmed that my
action for selecting the popup menu is being called. I'm sure I'm
missing something simply. Can someone help me?
Thanks, Chuck
_______________________________________________
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.