From 13cf693343722e3db261fa44eff1b0f8d9115e08 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 30 Sep 2010 17:09:03 +0000 Subject: [Author: dmaclach] Fix up GTMCarbonEvent to fix a major bug with comparing events. Also increases error checking and makes debugging easier. R=thomasvl DELTA=18 (6 added, 0 deleted, 12 changed) --- AppKit/GTMCarbonEvent.m | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'AppKit/GTMCarbonEvent.m') diff --git a/AppKit/GTMCarbonEvent.m b/AppKit/GTMCarbonEvent.m index 7753f1b..a0fd6ef 100644 --- a/AppKit/GTMCarbonEvent.m +++ b/AppKit/GTMCarbonEvent.m @@ -578,17 +578,17 @@ GTMOBJECT_SINGLETON_BOILERPLATE(GTMCarbonEventDispatcherHandler, userInfo:userInfo whenPressed:onKeyDown] autorelease]; require(newKey, CantCreateKey); - if (RegisterEventHotKey((UInt32)keyCode, - GTMCocoaToCarbonKeyModifiers(cocoaModifiers), - keyID, - [self eventTarget], - 0, - &theRef) == noErr) { - [newKey setHotKeyRef:theRef]; - [hotkeys_ addObject:newKey]; - } else { - newKey = nil; - } + require_noerr_action(RegisterEventHotKey((UInt32)keyCode, + GTMCocoaToCarbonKeyModifiers(cocoaModifiers), + keyID, + [self eventTarget], + 0, + &theRef), + CantRegisterHotKey, newKey = nil); + [newKey setHotKeyRef:theRef]; + [hotkeys_ addObject:newKey]; + +CantRegisterHotKey: CantCreateKey: return newKey; } @@ -704,7 +704,7 @@ CantCreateKey: - (BOOL)isEqual:(id)object { return [object isMemberOfClass:[self class]] - && (hotKeyRef_ = [object hotKeyRef]); + && (hotKeyRef_ == [object hotKeyRef]); } // Does this record match key |keyID| @@ -744,6 +744,12 @@ CantCreateKey: - (void)setHotKeyRef:(EventHotKeyRef)ref { hotKeyRef_ = ref; } + +- (NSString *)description { + return [NSString stringWithFormat:@"<%@ %p> - ref %p signature %d id %d", + [self class], self, hotKeyRef_, id_.signature, id_.id]; +} + @end -- cgit v1.2.3