Re: Enabling NSMenuItem in Code?
Re: Enabling NSMenuItem in Code?
- Subject: Re: Enabling NSMenuItem in Code?
- From: James Chen <email@hidden>
- Date: Wed, 21 Apr 2004 09:50:33 +0800
Hi,
Since the default behavior of menu enabling is "Automatic". (Please
refer to
http://developer.apple.com/documentation/Cocoa/Conceptual/MenuList/
Tasks/EnablingMenuItems.html)
That is, once the target of menu item implements the action of it then
the menu item will be enabled.
So one thine left you have to do is:
after your code
NSMenuItem *menuItem = [IconsMenu addItemWithTitle:@"New Menu Item"
action:@selector(MenuItemSelected:) keyEquivalent:@""];
[menuItem setTarget:theTarget]; // theTarget which implements method
MenuItemSelected:
I think that menuItem will be enabled.
HTH,
James
------------------------------------
Ulead Systems Inc.
James Chen
Software Engineer
Image Div.
------------------------------------
On Apr 21, 2004, at 8:38 AM, David Piasecki wrote:
I added an NSMenuItem to one of my NSMenu's using Objective-C, but I
can't figure out how to enable the menu item. Right now it's grey. I
can't figure out how to make it black and hence selectable by the user.
The code I used to add the menu item.
[IconsMenu addItemWithTitle:@"New Menu Item"
action:@selector(MenuItemSelected:) keyEquivalent:@""];
I also tried forcing it to be enabled, but since it didn't work, I
guess "enabled" is the wrong term.
[[IconsMenu itemWithTitle:@"New Menu Item"] setEnabled:true];
David
_______________________________________________
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.
_______________________________________________
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.