Re: Programming Context Menu
Re: Programming Context Menu
- Subject: Re: Programming Context Menu
- From: Graham Cox <email@hidden>
- Date: Tue, 05 Apr 2011 16:10:29 +1000
On 05/04/2011, at 1:37 PM, Bing Li wrote:
> I noticed that no IBAction/IBOutlet is available for the items in the code.
> Should I make some connections for them?
Yes, but the outlets aren't visible to code because 'IBOutlet' is an IB thing.
You need to call -setTarget: on the menu items with the view that is the target for the command. If you don't the target by default is nil i.e. 'First Responder'. That is usually not what you want for contextual menus which should be operable without becoming first responder.
You still may find that the items aren't enabled, depending on whether -validateMenuItem: or -validateUserInterfaceItem: is implemented and if so, whether it takes steps to enable the items.
There's plenty of info about this in the relevant docs.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden