1

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

pvinis
  • 4,059
  • 5
  • 39
  • 59
  • is there no way to do this? Instead of coding every menu item in the menu, I want to use a menu in the nib file. – pvinis Jan 27 '11 at 17:41

2 Answers2

2

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

[statusItem setMenu: statusItemMenu];

Ross Carter
  • 552
  • 4
  • 12
  • Yes I tried that, but IBOutlet means that my code will make something in the nib.. I want the opposite. I made the manu, and I need my code to see that. – pvinis Jan 26 '11 at 21:36
0

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.

ctietze
  • 2,805
  • 25
  • 46