Re: Detect modifier keys on launch
Re: Detect modifier keys on launch
- Subject: Re: Detect modifier keys on launch
- From: "Doug Knowles" <email@hidden>
- Date: Thu, 6 Jul 2006 11:10:59 -0400
[Posting to the list this time... :-} ]
FWIW, NSApplication's currentEvent returns nil in
applicationWillFinishLaunching and applicationDidFinishLaunching, as
well as applicationShouldOpenUntitledFile, which is where I was trying
to use it. I imagine that this is because the app hasn't processed an
event yet.
GetCurrentEventKeyModifiers(), however, did the trick (in
applicationShouldOpenUntitledFile, and I'm sure it would have worked
elsewhere).
For those who find this in their own search of the archives, invoking
GetCurrentEventKeyModifiers() from a Cocoa app required the following
(pardon me if this seems to obvious, and I hope this is the right way
to go about it...):
- add "/System/Library/Frameworks/Carbon.framework" to your project (I
put it in the "Linked Frameworks" group next to Cocoa.framework, and
checked the "add to target box);
- #import "Carbon/Carbon.h" in the source file that uses
GetCurrentEventKeyModifiers().
Once again, thanks to Sean McBride for the pointer (and the followup).
- Doug K;
P.S. It's kinda funny; I wrote a lot of code on the Mac starting in
1984, and now I'm learning how to use the classic APIs again.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden