summaryrefslogtreecommitdiffstats
path: root/DDHotKeyAppDelegate.m
diff options
context:
space:
mode:
Diffstat (limited to 'DDHotKeyAppDelegate.m')
-rw-r--r--DDHotKeyAppDelegate.m26
1 files changed, 26 insertions, 0 deletions
diff --git a/DDHotKeyAppDelegate.m b/DDHotKeyAppDelegate.m
index aeffd7a..a091fc6 100644
--- a/DDHotKeyAppDelegate.m
+++ b/DDHotKeyAppDelegate.m
@@ -7,6 +7,7 @@
//
#import "DDHotKeyAppDelegate.h"
+#import "DDHotKeyCenter.h"
@implementation DDHotKeyAppDelegate
@@ -14,6 +15,31 @@
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
+
+ DDHotKeyCenter * center = [[DDHotKeyCenter alloc] init];
+
+ [center registerHotKeyWithTarget:self action:@selector(hotkeyWithEvent:) object:nil keyCode:9 modifierFlags:NSControlKeyMask];
+ [center registerHotKeyWithTarget:self action:@selector(hotkeyWithEvent:object:) object:@"foo!" keyCode:9 modifierFlags:(NSControlKeyMask | NSAlternateKeyMask)];
+
+ int theAnswer = 42;
+ [center registerHotKeyWithBlock:^(NSEvent *hkEvent) {
+ NSLog(@"Firing block hotkey");
+ NSLog(@"Hotkey event: %@", hkEvent);
+ NSLog(@"the answer is: %d", theAnswer);
+ } keyCode:9 modifierFlags:(NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask)];
+
+ [center release];
+}
+
+- (void) hotkeyWithEvent:(NSEvent *)hkEvent {
+ NSLog(@"Firing -[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
+ NSLog(@"Hotkey event: %@", hkEvent);
+}
+
+- (void) hotkeyWithEvent:(NSEvent *)hkEvent object:(id)anObject {
+ NSLog(@"Firing -[%@ %@]", NSStringFromClass([self class]), NSStringFromSelector(_cmd));
+ NSLog(@"Hotkey event: %@", hkEvent);
+ NSLog(@"Object: %@", anObject);
}
@end