• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: HotKeys in Cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: HotKeys in Cocoa
      • From: Pierre-Olivier Latour <email@hidden>
References: 
 >Re: HotKeys in Cocoa (From: Alexandre Aybes <email@hidden>)

  • Prev by Date: (Newbie)Missing Header Files, Please Help
  • Next by Date: JComponent-like functionality in Cocoa/Obj-C
  • Previous by thread: Re: HotKeys in Cocoa
  • Next by thread: Re: HotKeys in Cocoa
  • Index(es):
    • Date
    • Thread