Re: Control key
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
References: | |
| >Control key (From: David Remahl <email@hidden>) |