From 14d386b499c8495b3725469cc0cd3393e0c613e6 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Wed, 29 Sep 2010 23:37:56 +0000 Subject: [Author: aharper] GTMHotKeyTextField on 10.4 again, properties are too new, so write custom accessors. DELTA=47 (29 added, 18 deleted, 0 changed) R=dmaclach --- AppKit/GTMHotKeyTextField.h | 21 +++++++++------------ AppKit/GTMHotKeyTextField.m | 26 ++++++++++++++++++++------ 2 files changed, 29 insertions(+), 18 deletions(-) (limited to 'AppKit') diff --git a/AppKit/GTMHotKeyTextField.h b/AppKit/GTMHotKeyTextField.h index cd671f0..cdd7830 100644 --- a/AppKit/GTMHotKeyTextField.h +++ b/AppKit/GTMHotKeyTextField.h @@ -33,16 +33,6 @@ BOOL doubledModifier_; } -// Modifier flags are stored using Cocoa constants (same as NSEvent) you will -// need to translate them to Carbon modifier flags for use with -// RegisterEventHotKey() -@property (readonly) NSUInteger modifiers; -// Virtual keycode. For double-modifier hotkeys this value is ignored. -@property (readonly) NSUInteger keyCode; -//Double-tap modifier keys cannot be used with RegisterEventHotKey(), you must -// implement your own Carbon event handler. -@property (readonly) BOOL doubledModifier; - + (id)hotKeyWithKeyCode:(NSUInteger)keyCode modifiers:(NSUInteger)modifiers useDoubledModifier:(BOOL)doubledModifier; @@ -50,6 +40,12 @@ - (id)initWithKeyCode:(NSUInteger)keyCode modifiers:(NSUInteger)modifiers useDoubledModifier:(BOOL)doubledModifier; + +// Custom accessors (readonly, nonatomic) +- (NSUInteger)modifiers; +- (NSUInteger)keyCode; +- (BOOL)doubledModifier; + @end // Notes: @@ -111,9 +107,10 @@ GTMHotKeyTextFieldCell *cell_; } -@property (retain) GTMHotKeyTextFieldCell *cell; - // Get the shared field editor for all hot key fields + (GTMHotKeyFieldEditor *)sharedHotKeyFieldEditor; +// Custom accessors (retain, nonatomic) +- (GTMHotKeyTextFieldCell *)cell; + @end diff --git a/AppKit/GTMHotKeyTextField.m b/AppKit/GTMHotKeyTextField.m index 27cd5b9..8c8703d 100644 --- a/AppKit/GTMHotKeyTextField.m +++ b/AppKit/GTMHotKeyTextField.m @@ -48,10 +48,6 @@ static CFStringRef kGTM_TISPropertyUnicodeKeyLayoutData = NULL; @implementation GTMHotKey -@synthesize modifiers = modifiers_; -@synthesize keyCode = keyCode_; -@synthesize doubledModifier = doubledModifier_; - + (id)hotKeyWithKeyCode:(NSUInteger)keyCode modifiers:(NSUInteger)modifiers useDoubledModifier:(BOOL)doubledModifier { @@ -71,6 +67,18 @@ static CFStringRef kGTM_TISPropertyUnicodeKeyLayoutData = NULL; return self; } +- (NSUInteger)modifiers { + return modifiers_; +} + +- (NSUInteger)keyCode { + return keyCode_; +} + +- (BOOL)doubledModifier { + return doubledModifier_; +} + - (BOOL)isEqual:(id)object { return [object isKindOfClass:[GTMHotKey class]] && [object modifiers] == [self modifiers] @@ -554,8 +562,6 @@ static CFStringRef kGTM_TISPropertyUnicodeKeyLayoutData = NULL; GTMOBJECT_SINGLETON_BOILERPLATE(GTMHotKeyFieldEditor, sharedHotKeyFieldEditor) -@synthesize cell = cell_; - - (id)init { if ((self = [super init])) { [self setFieldEditor:YES]; // We are a field editor @@ -571,6 +577,14 @@ GTMOBJECT_SINGLETON_BOILERPLATE(GTMHotKeyFieldEditor, sharedHotKeyFieldEditor) } // COV_NF_END +- (GTMHotKeyTextFieldCell *)cell { + return cell_; +} + +- (void)setCell:(GTMHotKeyTextFieldCell *)cell { + [cell_ autorelease]; + cell_ = [cell retain]; +} - (NSArray *)acceptableDragTypes { // Don't take drags -- cgit v1.2.3