Hotkey now gets registers with default values if no user data is present

This commit is contained in:
michael starke
2014-08-11 12:24:52 +02:00
parent be0ae27455
commit 113c620ead

View File

@@ -191,19 +191,25 @@ NSString *const kMPApplciationNameKey = @"applicationName";
#pragma mark Hotkey Registration #pragma mark Hotkey Registration
- (void)_registerHotKey { - (void)_registerHotKey {
if(nil == self.hotKeyData) {
return; // No hotkey data defined, so nothign to do
}
__weak MPAutotypeDaemon *welf = self; __weak MPAutotypeDaemon *welf = self;
DDHotKey *storedHotkey = [[DDHotKey alloc] initWithKeyData:self.hotKeyData taks:^(NSEvent *event) { DDHotKeyTask aTask = ^(NSEvent *event) {
[welf _didPressHotKey]; [welf _didPressHotKey];
}]; };
DDHotKey *storedHotkey;
if(nil == self.hotKeyData) {
storedHotkey = [DDHotKey hotKeyWithKeyCode:kVK_ANSI_M modifierFlags:kCGEventFlagMaskControl|kCGEventFlagMaskAlternate task:aTask];
}
else {
storedHotkey = [[DDHotKey alloc] initWithKeyData:self.hotKeyData taks:aTask];
}
self.registredHotKey = [[DDHotKeyCenter sharedHotKeyCenter] registerHotKey:storedHotkey]; self.registredHotKey = [[DDHotKeyCenter sharedHotKeyCenter] registerHotKey:storedHotkey];
} }
- (void)_unregisterHotKey { - (void)_unregisterHotKey {
if(nil != self.registredHotKey) {
[[DDHotKeyCenter sharedHotKeyCenter] unregisterHotKey:self.registredHotKey]; [[DDHotKeyCenter sharedHotKeyCenter] unregisterHotKey:self.registredHotKey];
self.registredHotKey = nil; self.registredHotKey = nil;
}
} }
- (NSDictionary *)_frontMostApplicationInfoDict { - (NSDictionary *)_frontMostApplicationInfoDict {