Re: An Example NSStatusItem with a menu
Re: An Example NSStatusItem with a menu
- Subject: Re: An Example NSStatusItem with a menu
- From: "Jere Gmail" <email@hidden>
- Date: Fri, 9 May 2008 09:58:52 +0200
it is easy. Just set the properties of the NSStatusItem. Then don't
state setMenu. Instead call setAction with a method.
[status_menu setAction:@selector(menuClick:)];
In that method you can add all the items you want. At the end of the
method you have to call the popUpStatusItemMenu method to display the
method.
This way you can enable or disable items depending on app variables
- (IBAction)menuClick:(id)sender
{
NSMenu *menu=[[[NSMenu alloc] initWithTitle:@""] autorelease];
[menu setAutoenablesItems:false];
NSMenuItem *it=[[[NSMenuItem alloc] initWithTitle:@"Prefs"
action:@selector(showPrefs:) keyEquivalent:@""] autorelease];
if([win_preferences isVisible])
[it setEnabled:false];
[it setTarget:self];
[menu addItem:it];
it=[[[NSMenuItem alloc] initWithTitle:@"Quit"
action:@selector(closeApplication:) keyEquivalent:@""] autorelease];
[it setTarget:self];
[menu addItem:it];
[status_menu popUpStatusItemMenu:menu];
}
Hope it helps
--
http://zonsoftware.wordpress.com/
And again we fall.
_______________________________________________
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