Re: Key Check at Startup
Re: Key Check at Startup
- Subject: Re: Key Check at Startup
- From: David Remahl <email@hidden>
- Date: Wed, 19 Jun 2002 21:16:56 +0200
>
Hi List!
>
I want my app to check whether the option key is pressed at startup.
>
I searched the Documentation, but I haven9t found anything. I9d be glad to
>
further tell you something about it but I don9t know anything. I hope this
>
makes sense...
>
>
Thanks,
>
Martin
This has been mentioned a few times on the list before. You will have to use
Carbon to get the state of a modifier without having an NSEvent to play
with. Here is a category to do it.
/ Regards, David Remahl
---
#import "NSEvent-CarbonAdditions.h"
#import <Carbon/Carbon.h>
@implementation NSEvent (ModifierKeys)
+ (BOOL) isControlKeyDown
{
return (GetCurrentKeyModifiers() & controlKey) != 0;
}
+ (BOOL) isOptionKeyDown
{
return (GetCurrentKeyModifiers() & optionKey) != 0;
}
+ (BOOL) isCommandKeyDown
{
return (GetCurrentKeyModifiers() & cmdKey) != 0;
}
+ (BOOL) isShiftKeyDown
{
return (GetCurrentKeyModifiers() & shiftKey) != 0;
}
@end
_______________________________________________
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.