• 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: Quit menu item undimming itself?!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Quit menu item undimming itself?!


  • Subject: Re: Quit menu item undimming itself?!
  • From: John Stiles <email@hidden>
  • Date: Tue, 9 May 2006 14:08:41 -0700

On May 9, 2006, at 1:32 PM, John Stiles wrote:

On May 9, 2006, at 12:13 PM, j o a r wrote:


On 9 maj 2006, at 21.06, John Stiles wrote:

This is set. I didn't even know about this option before :)
I assume there would be ramifications for disabling it, right? So what is the best course of action here?

You basically have two choices:

1) Use the super-elite first-responder empowered auto-validation. Implement NSMenuValidation in your menu item targets to control the enabled state of menu items when the default implementation is not enough. This is the best choice in the vast majority of cases.

2) Use manual validation. You have to enable / disable menu items yourself, as appropriate.

Either one works fine. Choose the one that suits you best!

In your case you might consider re-targeting the quit menu item to some object (probably your main controller class) that can implement NSMenuValidation to return NO when required.

That's probably best. I just want to control validation on this one item and leave the rest of the menu alone.

For the archives, this solution works great. It only required retargeting the Quit menu item to point to my main class, and implementing some trivial code:


- (IBAction) quit:(id)sender
{
	[NSApp terminate:s_mainClass];
}

- (BOOL)validateMenuItem:(NSMenuItem *)item
{
	// The only menu item we handle is Quit.
	return s_quitDisabled == 0;
}

And of course the code which used to disable the quit item now manages s_quitDisabled. Thanks, joar!! :) I didn't know anything about Cocoa's menu enabling semantics, but it's not tough at all once you know how the pieces fit together.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Quit menu item undimming itself?! (From: John Stiles <email@hidden>)
 >Re: Quit menu item undimming itself?! (From: j o a r <email@hidden>)
 >Re: Quit menu item undimming itself?! (From: John Stiles <email@hidden>)
 >Re: Quit menu item undimming itself?! (From: j o a r <email@hidden>)
 >Re: Quit menu item undimming itself?! (From: John Stiles <email@hidden>)

  • Prev by Date: Re: Quit menu item undimming itself?!
  • Next by Date: Re: Quit menu item undimming itself?!
  • Previous by thread: Re: Quit menu item undimming itself?!
  • Next by thread: Re: Quit menu item undimming itself?!
  • Index(es):
    • Date
    • Thread