Nick Van Brunt
Nick Van Brunt

Reputation: 15464

NSMenu with IBAction method for clicking the menu header?

How can I capture the selection of a NSMenu header with an IBAction method created in connection with interface builder? I am not sure "header" is the right word so see the image below:

alt text
(source: physle.com)

Is it possible to create an action for this the way you can with the selection of regular NSMenuItems? I can create the relationship in interface builder but the method never fires.

Upvotes: 2

Views: 677

Answers (1)

Dave DeLong
Dave DeLong

Reputation: 243146

Not exactly, but you can do it. If you acquire a pointer to the File menu itself, you can give it a delegate object. One of the methods of the NSMenuDelegate protocol is (void)menuWillOpen:(NSMenu *)menu. You could probably use this to achieve the same effect as a target-action mechanism.

Upvotes: 4

Related Questions