Re: How do I enable a menu item?
Re: How do I enable a menu item?
- Subject: Re: How do I enable a menu item?
- From: Alex Rice <email@hidden>
- Date: Sat, 30 Mar 2002 18:56:53 -0700
On Saturday, March 30, 2002, at 06:34 PM, Tony Gray wrote:
Hi,
I'm still learning Cocoa.
Still! Phshaaaw-- there are only approx 300 classes ;-)
I've just added my own menu item my application's
application menu, and (when this is selected) I want this to call a
method
in my application's controller. I can wire this up OK, but the problem
is,
this new menu is disabled, both when I test the interface in IB, and
when I
compile and run my app.
Do I have to programmatically enable my own custom menu items, or have I
missed something obvious (or otherwise!) in IB?
The default is for dynamic enabling of menu items. This gives you a lot
of control, but also you have to do a little extra work up front to
enable them in them in first place: Implement this method in the class
that's receiving the action of the menu item in question:
- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem
{
if ([item action] == @selector(doit:))
return YES;
return NO;
}
Alex Rice <email@hidden>
Mindlube Software
http://www.mindlube.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.