# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1606777868 0 # Node ID 70460d0afd03dfc4b6c22d0b65d5e84943ab8a9b # Parent a43a3f80ed32c52ce7a4f122eaa8613b63802636 Mac: Attempt to restore the Container/Listbox focus rings. This used to work before switching to NSView based instead of NSCell based NSTableViews. diff -r a43a3f80ed32 -r 70460d0afd03 mac/dw.m --- a/mac/dw.m Sun Nov 29 08:31:47 2020 +0000 +++ b/mac/dw.m Mon Nov 30 23:11:08 2020 +0000 @@ -2417,6 +2417,45 @@ } #endif +@interface DWFocusRingScrollView : NSScrollView +{ + BOOL shouldDrawFocusRing; + NSResponder* lastResp; +} +@end + +@implementation DWFocusRingScrollView +-(BOOL)needsDisplay; +{ + NSResponder* resp = nil; + + if([[self window] isKeyWindow]) + { + resp = [[self window] firstResponder]; + if (resp == lastResp) + return [super needsDisplay]; + } + else if (lastResp == nil) + { + return [super needsDisplay]; + } + shouldDrawFocusRing = (resp != nil && [resp isKindOfClass:[NSView class]] && [(NSView*)resp isDescendantOf:self]); + lastResp = resp; + [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]]; + return YES; +} +-(void)drawRect:(NSRect)rect +{ + [super drawRect:rect]; + + if(shouldDrawFocusRing) + { + NSSetFocusRingStyle(NSFocusRingOnly); + NSRectFill(rect); + } +} +@end + /* Subclass for a Container/List type */ @interface DWContainer : NSTableView #ifdef BUILDING_FOR_SNOW_LEOPARD @@ -5759,7 +5798,7 @@ /* Internal common function to create containers and listboxes */ HWND _dw_cont_new(ULONG cid, int multi) { - NSScrollView *scrollview = [[NSScrollView alloc] init]; + DWFocusRingScrollView *scrollview = [[DWFocusRingScrollView alloc] init]; DWContainer *cont = [[DWContainer alloc] init]; [cont setScrollview:scrollview];