diff options
| -rw-r--r-- | Framework/MASHotKey.m | 2 | ||||
| -rw-r--r-- | Framework/MASShortcutMonitor.h | 2 | ||||
| -rw-r--r-- | Framework/MASShortcutMonitor.m | 11 | 
3 files changed, 10 insertions, 5 deletions
| diff --git a/Framework/MASHotKey.m b/Framework/MASHotKey.m index 7886440..c5ab744 100644 --- a/Framework/MASHotKey.m +++ b/Framework/MASHotKey.m @@ -19,7 +19,7 @@ FourCharCode const MASHotKeySignature = 'MASS';      EventHotKeyID hotKeyID = { .signature = MASHotKeySignature, .id = _carbonID };      OSStatus status = RegisterEventHotKey([shortcut carbonKeyCode], [shortcut carbonFlags], -        hotKeyID, GetEventDispatcherTarget(), kEventHotKeyExclusive, &_hotKeyRef); +        hotKeyID, GetEventDispatcherTarget(), 0, &_hotKeyRef);      if (status != noErr) {          return nil; diff --git a/Framework/MASShortcutMonitor.h b/Framework/MASShortcutMonitor.h index 609686a..6d7fe82 100644 --- a/Framework/MASShortcutMonitor.h +++ b/Framework/MASShortcutMonitor.h @@ -18,7 +18,7 @@      Attempting to insert an already registered shortcut probably won’t work.      It may burn your house or cut your fingers. You have been warned.  */ -- (void) registerShortcut: (MASShortcut*) shortcut withAction: (dispatch_block_t) action; +- (BOOL) registerShortcut: (MASShortcut*) shortcut withAction: (dispatch_block_t) action;  - (BOOL) isShortcutRegistered: (MASShortcut*) shortcut;  - (void) unregisterShortcut: (MASShortcut*) shortcut; diff --git a/Framework/MASShortcutMonitor.m b/Framework/MASShortcutMonitor.m index 099f4b1..fce8022 100644 --- a/Framework/MASShortcutMonitor.m +++ b/Framework/MASShortcutMonitor.m @@ -45,11 +45,16 @@ static OSStatus MASCarbonEventCallback(EventHandlerCallRef, EventRef, void*);  #pragma mark Registration -- (void) registerShortcut: (MASShortcut*) shortcut withAction: (dispatch_block_t) action +- (BOOL) registerShortcut: (MASShortcut*) shortcut withAction: (dispatch_block_t) action  {      MASHotKey *hotKey = [MASHotKey registeredHotKeyWithShortcut:shortcut]; -    [hotKey setAction:action]; -    [_hotKeys setObject:hotKey forKey:shortcut]; +    if (hotKey) { +        [hotKey setAction:action]; +        [_hotKeys setObject:hotKey forKey:shortcut]; +        return YES; +    } else { +        return NO; +    }  }  - (void) unregisterShortcut: (MASShortcut*) shortcut | 
