Re: HotKeys in Cocoa
Re: HotKeys in Cocoa
- Subject: Re: HotKeys in Cocoa
- From: Alexandre Aybes <email@hidden>
- Date: Mon, 19 Aug 2002 23:29:06 -0700
Okay, so, now I am trying out (for the first time) to write a
Carbon handler, and I should probably write that to the
carbon-dev list, but since it is in the context of a cocoa app,
I hope you'll forgive me.
Here is what I did (wrong?)
OSStatus hotKeyCallback(EventHandlerCallRef inHandlerCallRef,
EventRef inEvent, void *inUserData)
{
OSStatus status = 0;
NSLog(@"HOT KEY!!! HOT HOT HOT! %@", inUserData);
return status;
}
@implementation PreferencesPanelController (HotKeyControl)
// called from awakeFromNib
- (void)setHotKey
{
EventHandlerUPP handlerUpp = NewEventHandlerUPP(hotKeyCallback);
EventTypeSpec eventTypeSpec =
{
kEventClassKeyboard,
kEventHotKeyPressed
};
OSStatus status = InstallEventHandler(
GetApplicationEventTarget(),
handlerUpp,
1,
&eventTypeSpec,
self,
NULL); /* can be NULL */
NSLog(@"Register with status: %i, handlerUpp: %x",
(int)status, handlerUpp);
}
@end
the setHotKey message is called (and logs no error), but the
call back never is, I must be missing something completely
obvious and probably stupid, but I can't see it... :/ (Like I
said it is my very first try at carbon events).
and obviously, once the code actually works, I WILL dispose the
UPP correctly and all that, but I just wanted to try it out
first, so how is this supposed to work? (I tried on both Jaguar
and Puma).
Thanks,
Alex.
_______________________________________________
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.