Created
October 15, 2014 18:45
-
-
Save willemvds/6bec2b26a9a35aa668e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Global hotkey stuff using carbon example code. | |
What is OSX? What is Obj-c? Who am I? | |
.h | |
#import <Carbon/Carbon.h> | |
.m | |
EventHotKeyRef gMyHotKeyRef; | |
EventHotKeyID gMyHotKeyID; | |
EventTypeSpec eventType; | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
eventType.eventClass = kEventClassKeyboard; | |
eventType.eventKind = kEventHotKeyPressed; | |
InstallApplicationEventHandler(&MyHotKeyHandler, 1, &eventType, NULL, NULL); | |
gMyHotKeyID.signature = "whoknows1"; | |
gMyHotKeyID.id = 1; | |
RegisterEventHotKey(49, NULL, gMyHotKeyID, GetApplicationEventTarget(), 0, &gMyHotKeyRef); | |
} | |
OSStatus MyHotKeyHandler(EventHandlerCallRef nextHandler, EventRef theEvent, void *userData) | |
{ | |
printf("So like the key was pressed or something?\n"); | |
return noErr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment