From 8fc7567e2e9737fd258d1216fcdf0bbe8bc05024 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Wed, 17 Apr 2013 18:00:47 +0700 Subject: [PATCH] Use new focus ring API (10.7) --- .../OakAppKit/src/OakKeyEquivalentView.mm | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Frameworks/OakAppKit/src/OakKeyEquivalentView.mm b/Frameworks/OakAppKit/src/OakKeyEquivalentView.mm index b56dcee6..ac09c713 100644 --- a/Frameworks/OakAppKit/src/OakKeyEquivalentView.mm +++ b/Frameworks/OakAppKit/src/OakKeyEquivalentView.mm @@ -124,18 +124,13 @@ static NSString* const kRecordingPlaceholderString = @"…"; - (void)setKeyState:(NSUInteger)newState { - NSUInteger oldState = self.keyState; [super setKeyState:newState]; - BOOL didHaveFocus = (oldState & (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask)) == (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask); - BOOL doesHaveFocus = (newState & (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask)) == (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask); - if(didHaveFocus != doesHaveFocus) - [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]]; - BOOL doesHaveResponder = (newState & (OakViewViewIsFirstResponderMask)) == (OakViewViewIsFirstResponderMask); if(!doesHaveResponder) self.recording = NO; + BOOL doesHaveFocus = (newState & (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask)) == (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask); if(!doesHaveFocus && self.recording) self.displayString = kRecordingPlaceholderString; // reset potential display string from flagsChanged: } @@ -282,15 +277,16 @@ static NSString* const kRecordingPlaceholderString = @"…"; NSImage* image = self.mouseInClearButton ? (_mouseDown ? imgDown : imgHover) : imgNormal; [image drawAdjustedInRect:_clearButtonRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0]; } +} - BOOL doesHaveFocus = (self.keyState & (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask)) == (OakViewViewIsFirstResponderMask|OakViewWindowIsKeyMask|OakViewApplicationIsActiveMask); - if(doesHaveFocus) - { - [NSGraphicsContext saveGraphicsState]; - NSSetFocusRingStyle(NSFocusRingOnly); - NSRectFill(frame); - [NSGraphicsContext restoreGraphicsState]; - } +- (void)drawFocusRingMask +{ + NSRectFill([self bounds]); +} + +- (NSRect)focusRingMaskBounds +{ + return [self bounds]; } // ============