Re: Getting the current state of the modifier keys
Re: Getting the current state of the modifier keys
- Subject: Re: Getting the current state of the modifier keys
- From: Greg Titus <email@hidden>
- Date: Sat, 22 Feb 2003 14:03:37 -0800
On Saturday, February 22, 2003, at 01:07 PM, Jeffrey Mattox wrote:
>
I have a Cocoa routine that gets a single keystroke or mouse click
>
event. If a modifier key is down, I want to wait until the modifier
>
key is released before proceeding. My routine only gets the one
>
event, not any others. Is there a way to test the current state of
>
the modifiers without getting another event?
No. But you can just keep getting flag changed events until the
modifier changes.
>
>
I know how to test the event to see if a modifier key was on, but I
>
need to wait for the key(s) to be released.
You need to run your own little modal event loop, and wait until you
get a flags changed event with the modifier released:
NSEvent *event;
do {
theEvent = [NSApp nextEventMatchingMask:NSFlagsChangedMask
untilDate:[NSDate distantFuture] inMode:NSEventTrackingRunLoopMode
dequeue:YES];
} while ([theEvent modifierFlags] & NSAlternateKeyMask);
Hope this helps,
- Greg
_______________________________________________
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.