Re: Option key state
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.