Question

I put a NSMenuItem in the MainMenu.xib of a document-based application. I can set a key equiv. for this item in Interface Builder, anyway that item can't call an IBAction defined in the NSDocument subclass instance (which exists in MyDocument.xib). How can I make that button call an action from a different xib (if it is possible)?

Thank you in advance.

—Albé

Was it helpful?

Solution

Connect your menu item to the First Responder. When a document window is active, its document is in the responder chain so that it can respond to actions like the one you assigned to your menu item.

Note that you can only hook it up to your action after you've declared your action in a class's header. It doesn't matter whether that class is instantiated in the MainMenu nib or not; as long as the action is declared in the header and the header and MainMenu nib are both in the same project, IB will know that what you're doing is valid. If you haven't declared the action yet, it won't show up in IB's list of possible actions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top