Created
May 19, 2009 20:27
-
-
Save isaac/114372 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#import <Foundation/Foundation.h> | |
#import <Cocoa/Cocoa.h> | |
#import <Carbon/Carbon.h> | |
@interface Shortcut : NSObject | |
@end | |
OSStatus myHotKeyHandler(EventHandlerCallRef nextHandler, EventRef anEvent, void *userData); | |
@implementation Shortcut | |
- (void)addShortcut | |
{ | |
EventHotKeyRef myHotKeyRef; | |
EventHotKeyID myHotKeyID; | |
EventTypeSpec eventType; | |
eventType.eventClass=kEventClassKeyboard; | |
eventType.eventKind=kEventHotKeyPressed; | |
InstallApplicationEventHandler(&myHotKeyHandler,1,&eventType,NULL,NULL); | |
myHotKeyID.signature='mhk1'; | |
myHotKeyID.id=1; | |
RegisterEventHotKey(49, cmdKey+optionKey, myHotKeyID, GetApplicationEventTarget(), 0, &myHotKeyRef); | |
} | |
@end | |
OSStatus myHotKeyHandler(EventHandlerCallRef nextHandler, EventRef anEvent, void *userData) | |
{ | |
NSLog(@"YEAY WE DID A GLOBAL HOTKEY"); | |
return noErr; | |
} | |
void Init_shortcut(void) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment