X-Git-Url: http://git.ithinksw.org/ITKit.git/blobdiff_plain/5a5f8385d7cf8bca82ac4bafe96d1dd313a1bc24..1d5525ced75adc1fe1508e8c19fcc31af129464e:/ITHotKeyCenter.m diff --git a/ITHotKeyCenter.m b/ITHotKeyCenter.m index ad9c31d..2e43e56 100755 --- a/ITHotKeyCenter.m +++ b/ITHotKeyCenter.m @@ -50,6 +50,7 @@ static id _sharedHotKeyCenter = nil; if( self ) { mHotKeys = [[NSMutableDictionary alloc] init]; + _enabled = YES; } return self; @@ -63,6 +64,16 @@ static id _sharedHotKeyCenter = nil; #pragma mark - +- (BOOL)isEnabled +{ + return _enabled; +} + +- (void)setEnabled:(BOOL)flag +{ + _enabled = flag; +} + - (BOOL)registerHotKey: (ITHotKey*)hotKey { OSStatus err; @@ -185,6 +196,10 @@ static id _sharedHotKeyCenter = nil; long subType; EventHotKeyRef carbonHotKey; + if (!_enabled) { + return; + } + //We only have to intercept sendEvent to do hot keys on old system versions if( [self _hasCarbonEventSupport] ) return; @@ -219,7 +234,11 @@ static id _sharedHotKeyCenter = nil; OSStatus err; EventHotKeyID hotKeyID; ITHotKey* hotKey; - + + if (!_enabled) { + return -1; + } + NSAssert( [self _hasCarbonEventSupport], @"" ); NSAssert( GetEventClass( event ) == kEventClassKeyboard, @"Unknown event class" );