Re: Disabling Menu Items.
Re: Disabling Menu Items.
- Subject: Re: Disabling Menu Items.
- From: Citizen <email@hidden>
- Date: Fri, 23 Feb 2007 13:59:14 +0000
On 23 Feb 2007, at 12:38, MANISH CHATURVEDI wrote:
I've created the Menu of my cocoa application using Interface
builder.I want to disable the sub menu "Prefrences.." when my
application runs.
Do you mean when it is busy or do you want to disable the
preferences.. item completely?
If it is the second, then you can just remove that item using
interface Builder.
I think I need to override the method -(void)validateMenuItem:
to Enable/Disable the menu,but not sure how to use this.
That's correct.
You'll need something like this in the class that responds to the
preferences... menu item action:
- (BOOL) validateMenuItem:(NSMenuItem *)menuItem
{
SEL menuAction = [menuItem action];
if (menuAction == @selector(showPreferencePanel:)) {
if (canDisplayPreferences) {
return YES;
} else {
return NO;
}
}
return YES; // return YES here so all other menu items are displayed
}
Where "showPreferencePanel:" is the action for your preference menu
item and the BOOL value for canDisplayPreferences is set to whatever
you require.
Is there is any document for this?
Should I use the NSMenuItem methods to do this? I've seen some
sample code for this but again unsure about the creation of
Menu.Can I use the NSMenuItem methods to enable/disable the menu at
run time.
The first method is preferred.
If you do it this second way you are likely to see your changes
overridden.
Hope that helps,
Dave
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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