From 1d5525ced75adc1fe1508e8c19fcc31af129464e Mon Sep 17 00:00:00 2001 From: Kent Sutherland Date: Sat, 25 Sep 2004 23:53:29 +0000 Subject: [PATCH] Added a disable/enable method to the hotkey center --- ITHotKeyCenter.h | 4 ++++ ITHotKeyCenter.m | 21 ++++++++++++++++++++- ITKit.xcode/project.pbxproj | 15 ++++----------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ITHotKeyCenter.h b/ITHotKeyCenter.h index 3c8bb4c..347110f 100755 --- a/ITHotKeyCenter.h +++ b/ITHotKeyCenter.h @@ -22,10 +22,14 @@ { NSMutableDictionary* mHotKeys; //Keys are NSValue of EventHotKeyRef BOOL mEventHandlerInstalled; + BOOL _enabled; } + (id)sharedCenter; +- (BOOL)isEnabled; +- (void)setEnabled:(BOOL)flag; + - (BOOL)registerHotKey: (ITHotKey*)hotKey; - (void)unregisterHotKey: (ITHotKey*)hotKey; 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" ); diff --git a/ITKit.xcode/project.pbxproj b/ITKit.xcode/project.pbxproj index 1e394fa..2e5e568 100755 --- a/ITKit.xcode/project.pbxproj +++ b/ITKit.xcode/project.pbxproj @@ -6,8 +6,6 @@ objectVersion = 39; objects = { 014CEA440018CDF011CA2923 = { - buildRules = ( - ); buildSettings = { COPY_PHASE_STRIP = NO; DEBUGGING_SYMBOLS = YES; @@ -22,8 +20,6 @@ name = Development; }; 014CEA450018CDF011CA2923 = { - buildRules = ( - ); buildSettings = { COPY_PHASE_STRIP = YES; GCC_ENABLE_FIX_AND_CONTINUE = NO; @@ -65,7 +61,7 @@ 0867D690FE84028FC02AAC07 = { buildSettings = { MACOSX_DEPLOYMENT_TARGET = 10.2; - SDKROOT = /Developer/SDKs/MacOSX10.2.7.sdk; + SDKROOT = /Developer/SDKs/MacOSX10.2.8.sdk; }; buildStyles = ( 014CEA440018CDF011CA2923, @@ -109,8 +105,7 @@ sourceTree = ""; }; 0867D69BFE84028FC02AAC07 = { - fallbackIsa = PBXFileReference; - isa = PBXFrameworkReference; + isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; @@ -118,8 +113,7 @@ sourceTree = ""; }; 0867D6A5FE840307C02AAC07 = { - fallbackIsa = PBXFileReference; - isa = PBXFrameworkReference; + isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; @@ -196,8 +190,7 @@ sourceTree = ""; }; 1058C7B1FEA5585E11CA2CBB = { - fallbackIsa = PBXFileReference; - isa = PBXFrameworkReference; + isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; -- 2.20.1