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

Re: Control key


  • Subject: Re: Control key
  • From: Fritz Anderson <email@hidden>
  • Date: Sun, 1 Jul 2001 08:07:17 -0500

At 11:25 AM +0200 7/1/2001, David Remahl wrote:
How do I detect if the control key is pressed at any point in my code, without having access to an NSEvent? I want to do this in a method called by a menu item...Do I have to resort to carbon?

Could be worse... be sure to call this as early in your action handler as possible, because you're in a race with the user, who will release the control key as soon as the menu is released.

See also the Carbon Event Manager, <Events.h>.

#import <Carbon/Carbon.h>

@interface NSEvent (ModifierKeys)
+ (BOOL) isControlKeyDown;
@end

@implementation NSEvent (ModifierKeys)

+ (BOOL) isControlKeyDown
{
return (GetCurrentKeyModifiers() & controlKey) != 0;
}

@end

-- F
--
Fritz Anderson <email@hidden>
Parallel Software, Inc <http://www.parallel.com/>
Naperville, Illinois


  • Follow-Ups:
    • Re: Control key
      • From: David Remahl <email@hidden>
    • Re: Control key
      • From: Gerard Iglesias <email@hidden>
References: 
 >Control key (From: David Remahl <email@hidden>)

  • Prev by Date: RE: [HELP] How to change Desktop background pic in OSX from Cocoa-Java?
  • Next by Date: Re: NSString, scramble
  • Previous by thread: Control key
  • Next by thread: Re: Control key
  • Index(es):
    • Date
    • Thread