Re: Option key state
Re: Option key state
- Subject: Re: Option key state
- From: Jens Bauer <email@hidden>
- Date: Mon, 11 Feb 2002 18:57:35 +0100
Hi Josh,
(anyone, feel free to override my message with a Cocoa native solution)
On Mon, 11 Feb, 2002, Josh Aas <email@hidden> 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.
As far as I remember, you can do this with Carbon; you can probably also
do it with Cocoa, if you didn't include Carbon already.
With Carbon, you have at least 2 options:
1: GetCurrentKeyModifiers
2: GetKeys
I'd suggest you use GetCurrentKeyModifiers, as it's the prettiest one.
GetKeys returns a map of the entire keyboard, which you would probably
not be interested in.
GetCurrentKeyModifiers returns a UInt32, which is the same format as the
one in the EventRecord.
if(result & (optionKey | rightOptionKey))
{
}
Should give you what you need in this case.
Love,
Jens
--
Jens Bauer, Faster Software.
_______________________________________________
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.