Pergunta

I have a Main.xib, with the main window, the main menu, and a second menu with a name "StatusMenu" that connects nowhere.

In my application, I have an NSStatusItem, and I want to press it, and display that secondary menu.

How can I connect those two?

thanks

Foi útil?

Solução

Create an IBOutlet for the status item menu, and then when you create the status item set its menu:

[statusItem setMenu: statusItemMenu];

Outras dicas

You should add an Object to Interface Builder and connect the visible menu to it. This object can be any custom class with an appropriate @IBOutlet. Just set the class in the "Identity Inspector".

This way, loadin the Nib will create an instance of your object as well. You then have to make sure this object is itself connected to an outlet of, say, AppDelegate, or else you won't be able to access it.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top