From 113c620ead197b727157e6951c4f47b7759236cc Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 11 Aug 2014 12:24:52 +0200 Subject: [PATCH] Hotkey now gets registers with default values if no user data is present --- MacPass/MPAutotypeDaemon.m | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/MacPass/MPAutotypeDaemon.m b/MacPass/MPAutotypeDaemon.m index 616da205..c94fe56d 100644 --- a/MacPass/MPAutotypeDaemon.m +++ b/MacPass/MPAutotypeDaemon.m @@ -191,19 +191,25 @@ NSString *const kMPApplciationNameKey = @"applicationName"; #pragma mark Hotkey Registration - (void)_registerHotKey { - if(nil == self.hotKeyData) { - return; // No hotkey data defined, so nothign to do - } __weak MPAutotypeDaemon *welf = self; - DDHotKey *storedHotkey = [[DDHotKey alloc] initWithKeyData:self.hotKeyData taks:^(NSEvent *event) { + DDHotKeyTask aTask = ^(NSEvent *event) { [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]; } - (void)_unregisterHotKey { - [[DDHotKeyCenter sharedHotKeyCenter] unregisterHotKey:self.registredHotKey]; - self.registredHotKey = nil; + if(nil != self.registredHotKey) { + [[DDHotKeyCenter sharedHotKeyCenter] unregisterHotKey:self.registredHotKey]; + self.registredHotKey = nil; + } } - (NSDictionary *)_frontMostApplicationInfoDict {