NSPopUpButton - menu exchange

  • 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 | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month june 2003 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Go to today