Re: iTunes-like behaviour of NSButton with NSAlternateKeyMask
Re: iTunes-like behaviour of NSButton with NSAlternateKeyMask
- Subject: Re: iTunes-like behaviour of NSButton with NSAlternateKeyMask
- From: Murat Konar <email@hidden>
- Date: Fri, 09 Feb 2007 12:25:47 -0800
On Feb 9, 2007, at 12:03 PM, Michael G. Ströck wrote:
Am 09.02.2007 um 20:41 schrieb Murat Konar:
iTunes and iPhoto keep monitoring the status of the Option key
even when they're in the background, and I can't figure out how
it's done. Can anybody here on the list give me any pointers?
Try this:
#import <Carbon/Carbon.h>
BOOL optionKeyIsDown()
{
return (GetCurrentKeyModifiers() & optionKey) != 0;
}
_murat
Thanks murat, but detecting the option key is, I believe, not the
problem, the problem is getting the button to change it's
appearance and action while your application does NOT have focus.
Where do I do that?
Aha. The problem is that your app, when not active, will not receive
key or any other events.
You could set up a timer (NSTimer) to periodically check the state of
the option key (but that would be polling), or if you're not afraid
of Carbon, see the "EventMonitorTest" sample code at
<http://developer.apple.com/referencelibrary/Carbon/
idxEventsOtherInput-date.html>
_murat_______________________________________________
Cocoa-dev mailing list (email@hidden)
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