Re: Repeating Hotkeys
Re: Repeating Hotkeys
- Subject: Re: Repeating Hotkeys
- From: Daniel Jalkut <email@hidden>
- Date: Tue, 5 Sep 2006 13:59:43 -0400
I see now by looking at the linked example that it only installs a
handler on one event type. This might be obvious but the syntax for
building the array of event types could be a stumbling block, and
since I have the code I thought I'd paste it. Example of how to
listen for both key down and key up messages:
- (EventHandlerRef) installHotKeyEventHandler
{
OSStatus eventErr;
EventTypeSpec myEventTypes[2] = {{kEventClassKeyboard,
kEventHotKeyPressed},
{ kEventClassKeyboard, kEventHotKeyReleased }};
EventHandlerRef hotKeyHandler;
// Install Carbon event handler to hear about hotkey events
eventErr = InstallEventHandler(GetApplicationEventTarget(),
NewEventHandlerUPP(MyHotKeyEventHandler), 2, myEventTypes, self /
*userdata*/, &hotKeyHandler);
if (eventErr != noErr)
{
hotKeyHandler = nil;
}
return hotKeyHandler;
}
Hope this helps,
Daniel
On Sep 5, 2006, at 12:38 PM, Alexander Repty wrote:
Hello everyone,
I recently implemented global hotkeys in my application using
Dustin Bachrach's fine tutorial: http://dbachrach.com/blog/2005/11/
program-global-hotkeys-in-cocoa-easily/
Everything works fine, but I have been trying to figure out how to
detect if the user presses and holds the hotkey, so I can
repeatedly invoke the corresponding method. Using my current
solution, the user has to release and press the button over again
if they want to repeat the action.
The documentation, Google and IRC did not come up with any
worthwhile results on this issue, so I'm hoping that someone here
has a clue for me. Many thanks in advance.
Cheers,
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com
This email sent to email@hidden
_______________________________________________
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