diff options
| author | Dave DeLong | 2012-12-29 13:30:00 -0800 |
|---|---|---|
| committer | Dave DeLong | 2012-12-29 13:30:00 -0800 |
| commit | bc90e5a3f070877f00e8f7e6fe99880555450284 (patch) | |
| tree | d1c4a6928d30d5d5b3497625e6b83315cc96a06e | |
| parent | 4ed465f39afdd215a21e2c7b651c4599dccd693a (diff) | |
| download | DDHotKey-bc90e5a3f070877f00e8f7e6fe99880555450284.tar.bz2 | |
Actually, you know, install the event handler.
| -rw-r--r-- | DDHotKeyCenter.m | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/DDHotKeyCenter.m b/DDHotKeyCenter.m index a5ae678..c8bbc7f 100644 --- a/DDHotKeyCenter.m +++ b/DDHotKeyCenter.m @@ -151,16 +151,17 @@ static DDHotKeyCenter *center = nil; + (id)sharedHotKeyCenter { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - center = [[DDHotKeyCenter alloc] _init]; + center = [[DDHotKeyCenter _alloc] _init]; }); return center; } ++ (id)_alloc { + return [super allocWithZone:nil]; +} + + (id)allocWithZone:(NSZone *)zone { - if (center == nil) { - return [super allocWithZone:zone]; - } - return DDHK_RETAIN(center); + return DDHK_RETAIN([self sharedHotKeyCenter]); } - (id)_init { @@ -168,6 +169,11 @@ static DDHotKeyCenter *center = nil; if (self) { _registeredHotKeys = [[NSMutableSet alloc] init]; _nextHotKeyID = 1; + + EventTypeSpec eventSpec; + eventSpec.eventClass = kEventClassKeyboard; + eventSpec.eventKind = kEventHotKeyReleased; + InstallApplicationEventHandler(&dd_hotKeyHandler, 1, &eventSpec, NULL, NULL); } return self; } @@ -182,8 +188,6 @@ static DDHotKeyCenter *center = nil; } - (BOOL)_registerHotKey:(DDHotKey *)hotKey { - BOOL success = NO; - EventHotKeyID keyID; keyID.signature = 'htk1'; keyID.id = _nextHotKeyID; @@ -202,7 +206,7 @@ static DDHotKeyCenter *center = nil; _nextHotKeyID++; [_registeredHotKeys addObject:hotKey]; - return success; + return YES; } - (void)unregisterHotKey:(DDHotKey *)hotKey { |
