• 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: Option key state
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Option key state


  • Subject: Re: Option key state
  • From: Michael Peirce <email@hidden>
  • Date: Mon, 11 Feb 2002 13:08:20 -0500

On Monday, February 11, 2002, at 12:27 PM, Josh Aas wrote:

I need to test whether the option key is being held down or not when my
application is launching. I only know how to check the option key's state
from an NSEvent, but I don't really have one. I need to check the option
key's state in the following method delegated by NSApplication.

- (BOOL)application:(NSApplication*)anApplication
openFile:(NSString*)aFileName
{
if (appIsLaunching) {
wasLaunchedWithDocument = YES;
// check here for option key's state
}
[self doSomeThing:[NSArray arrayWithObject:aFileName]];
return YES;
}

I've used something like the following a few times:

if (([[[NSApplication sharedApplication] currentEvent] modifierFlags] & NSShiftKeyMask) == 0) {

I see you have "anApplication" available so maybe you could use:

if (([[anApplication currentEvent] modifierFlags] & NSShiftKeyMask) == 0) {

Thanks! And I assume the name for the option key's keymask is
"NSAlternateKeyMask"?

Oh, my examples check for the Shift key, use NSAlternateKeyMask instead - it's found in NSEvent.h


The only draw back is that this is looking at the option key as of when the event happened.

--
Michael Peirce
6497 Spinnaker Drive
Lewis Center OH 43035
740-657-1269
email@hidden
_______________________________________________
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.

References: 
 >Option key state (From: Josh Aas <email@hidden>)

  • Prev by Date: Re: Option key state
  • Next by Date: Re: Option key state
  • Previous by thread: Re: Option key state
  • Next by thread: Re: Option key state
  • Index(es):
    • Date
    • Thread