Added a disable/enable method to the hotkey center
authorKent Sutherland <ksuther@ithinksw.com>
Sat, 25 Sep 2004 23:53:29 +0000 (23:53 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Sat, 25 Sep 2004 23:53:29 +0000 (23:53 +0000)
ITHotKeyCenter.h
ITHotKeyCenter.m
ITKit.xcode/project.pbxproj

index 3c8bb4c..347110f 100755 (executable)
 {
        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;
 
index ad9c31d..2e43e56 100755 (executable)
@@ -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" );
 
index 1e394fa..2e5e568 100755 (executable)
@@ -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,
                        sourceTree = "<group>";
                };
                0867D69BFE84028FC02AAC07 = {
-                       fallbackIsa = PBXFileReference;
-                       isa = PBXFrameworkReference;
+                       isa = PBXFileReference;
                        lastKnownFileType = wrapper.framework;
                        name = Foundation.framework;
                        path = /System/Library/Frameworks/Foundation.framework;
                        sourceTree = "<absolute>";
                };
                0867D6A5FE840307C02AAC07 = {
-                       fallbackIsa = PBXFileReference;
-                       isa = PBXFrameworkReference;
+                       isa = PBXFileReference;
                        lastKnownFileType = wrapper.framework;
                        name = AppKit.framework;
                        path = /System/Library/Frameworks/AppKit.framework;
                        sourceTree = "<group>";
                };
                1058C7B1FEA5585E11CA2CBB = {
-                       fallbackIsa = PBXFileReference;
-                       isa = PBXFrameworkReference;
+                       isa = PBXFileReference;
                        lastKnownFileType = wrapper.framework;
                        name = Cocoa.framework;
                        path = /System/Library/Frameworks/Cocoa.framework;