• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: An Example NSStatusItem with a menu
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >An Example NSStatusItem with a menu (From: "J. Todd Slack" <email@hidden>)

  • Prev by Date: Re: Crashes with NSOpenPanel and garbage collection
  • Next by Date: Re: How to send email without using email client
  • Previous by thread: An Example NSStatusItem with a menu
  • Next by thread: Dictionary Enumeration
  • Index(es):
    • Date
    • Thread