Re: Alternating Button
Re: Alternating Button
- Subject: Re: Alternating Button
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Fri, 4 Apr 2008 10:55:47 +0200
Le 3 Apr 2008 à 16:31, douglas a. welton a écrit :
Gerriet,
Check out the function GetCurrentEventKeyModifiers() in the
Carbon Event Manager reference:
<http://developer.apple.com/documentation/Carbon/Reference/
Carbon_Event_Manager_Ref/Reference/reference.html#//apple_ref/doc/
uid/TP30000135-DontLinkChapterID_1-DontLinkElementID_20>
regards,
douglas
On Apr 3, 2008, at 4:44 AM, Gerriet M. Denkmann wrote:
Llistening at NSWindowDidUpdateNotification (or probably better:
NSApplicationWillUpdateNotification) is certainly a good idea.
Whenever the modifier keys change (and on several other occasions
as well) an NSApplicationWillUpdateNotification gets send.
When I get such a notification I could, as you suggested, "make
the appropriate modifications to your button based on the state of
the keyboard."
But: how do I get this aforementioned state? [NSApp currentEvent]
might be the key-event, but I am not sure I can rely on this.
Maybe another event came after this and before the notification
gets sent.
I would like to have something like [NSApp currentModifierFlags]
(similar to [NSEvent modifierFlags])
Have checked it out. Did even implement it. Code got much simpler
this way. Thanks a lot!
The documentation says: " The queue-synchronized keyboard modifier
state indicates the modifier state according to the event most
recently dispatched through an event target. This state may be
different from the hardware state obtained using
GetCurrentKeyModifiers."
So I am (a little) worried about a scenario like this:
User presses ⌥-key, then some other event comes along (something not
keyboard related) and gets dispatched, and now NSApplication decides
to update, sends an NSApplicationWillUpdateNotification accordingly,
my method gets notified and tests CurrentEventKeyModifiers.
Will it see the ⌥-modifier or nothing (as the latest event is not
keyboard related)?
Did never see anything like this. Just some slight worry on the side.
Kind regards,
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden