NSPopUpButton - menu exchange
NSPopUpButton - menu exchange
- Subject: NSPopUpButton - menu exchange
- From: "Vincenzo Kreft-Kerekes" <email@hidden>
- Date: Wed, 18 Jun 2003 13:44:33 -0400
Dear All,
I can't seem to figure out how to exchange the menu of an NSPopUpButton
without causing assertion failures because the NSPopUpButtonCell tries to
select an item from the previous menu during the call to [NSPopUpButton
setMenu:] which in my case lies far beyond the bounds of the new menu, thus
causing an "out of bounds" error. From the assembly code of
[NSPopUpButtonCell setMenu:] it seems to scan through the items in the new
menu looking for an item with state != NSOffState and if this is not found
then it tries to select a item at indexOfSelectedItem (from the previous
menu!) the index of which is invalid.
I have pop-buttons in several views, one for each and never shown at the
same time, which share a dynamic menu and each view's button has different
enabled states for the items and its own selected item, autoenablesitems are
off. I understand, because of the issues I'm experiencing, that you
shouldn't change the menu owned by a popup-button directly but since the
menu is shared I would like to manage it in a controller object and
"distribute" it to all buttons rather than having to keep track of multiple
menus and changing each using its popup-button's methods. For the same
reason the menu items have target/action point to this controller thus not
using an IBAction connected to each button (why is the button action
actually never called if just one menu item has its own target/action?) and
I'm disabling items by setting their target to nil instead of to the
controller object, I know about NSMenuValidation. I also understand you can
use the button action and item tags to determine the target/action but I
can't seem to warp my head around which method is optimal for what situation
and how you can safely share a menu among popup-buttons. Sorry if this seems
like a dull and simple question but once I GDB into PowerPC assembly to see
what might be going on it means I've run completely out of ideas and would
greatly appreciate any help. Thanks a lot.
Best Regards,
Vincenzo
_______________________________________________
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.