• 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: Getting the current state of the modifier keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Getting the current state of the modifier keys
      • From: Jeffrey Mattox <email@hidden>
References: 
 >Getting the current state of the modifier keys (From: Jeffrey Mattox <email@hidden>)

  • Prev by Date: Re: Enumerating Address Book properties
  • Next by Date: Re: tools for finding a bug?
  • Previous by thread: Getting the current state of the modifier keys
  • Next by thread: Re: Getting the current state of the modifier keys
  • Index(es):
    • Date
    • Thread