tags:

views:

82

answers:

1

Hi,

I need to share the same NSMenu instance between multiple popup buttons.

When I create an NSPopUpButton in IB, a new menu is automatically created and inserted as a child of the NSPopUpButtonCell.

At the moment, I simply create an IBOutlet NSMenuItem* standardMenu member in my MainController and connect the "menu" outlets of the popup buttons to this, but this leaves the "fake" menus in the hierarchy.

Surely, there's a clean way of doing this from inside IB?

Thanks in advance for any advice you might be able to give.

+1  A: 

You should be able to build a freestanding menu in IB make all the connections, etc. you need. Then create an outlet IBOutlet NSMenu *standardMenu; that you connect to the menu in IB. Then for each popup that needs the menu just use [popupButton setMenu:standardMenu];. If for some reason it keeps the old items just tell it to remove all items first.

theMikeSwan
Thanks. That's why I ended up doing after IB gave me plenty of problems when trying to connect the menu outlet of the popup button (it can be done but only using the "referencing outlets" in reverse).Still I would have hoped that there would be a better way than to keep links to all popupbutton and programmatically set them.. one of those rough edges in AppKit and IB..
Frank R.