Mercurial > dwindows
comparison mac/dw.m @ 2206:70460d0afd03
Mac: Attempt to restore the Container/Listbox focus rings. This used to work
before switching to NSView based instead of NSCell based NSTableViews.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 30 Nov 2020 23:11:08 +0000 |
parents | f0611d5385f9 |
children | 2c82060fda42 |
comparison
equal
deleted
inserted
replaced
2205:a43a3f80ed32 | 2206:70460d0afd03 |
---|---|
2415 [tf setFrame:rect]; | 2415 [tf setFrame:rect]; |
2416 } | 2416 } |
2417 } | 2417 } |
2418 #endif | 2418 #endif |
2419 | 2419 |
2420 @interface DWFocusRingScrollView : NSScrollView | |
2421 { | |
2422 BOOL shouldDrawFocusRing; | |
2423 NSResponder* lastResp; | |
2424 } | |
2425 @end | |
2426 | |
2427 @implementation DWFocusRingScrollView | |
2428 -(BOOL)needsDisplay; | |
2429 { | |
2430 NSResponder* resp = nil; | |
2431 | |
2432 if([[self window] isKeyWindow]) | |
2433 { | |
2434 resp = [[self window] firstResponder]; | |
2435 if (resp == lastResp) | |
2436 return [super needsDisplay]; | |
2437 } | |
2438 else if (lastResp == nil) | |
2439 { | |
2440 return [super needsDisplay]; | |
2441 } | |
2442 shouldDrawFocusRing = (resp != nil && [resp isKindOfClass:[NSView class]] && [(NSView*)resp isDescendantOf:self]); | |
2443 lastResp = resp; | |
2444 [self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]]; | |
2445 return YES; | |
2446 } | |
2447 -(void)drawRect:(NSRect)rect | |
2448 { | |
2449 [super drawRect:rect]; | |
2450 | |
2451 if(shouldDrawFocusRing) | |
2452 { | |
2453 NSSetFocusRingStyle(NSFocusRingOnly); | |
2454 NSRectFill(rect); | |
2455 } | |
2456 } | |
2457 @end | |
2458 | |
2420 /* Subclass for a Container/List type */ | 2459 /* Subclass for a Container/List type */ |
2421 @interface DWContainer : NSTableView | 2460 @interface DWContainer : NSTableView |
2422 #ifdef BUILDING_FOR_SNOW_LEOPARD | 2461 #ifdef BUILDING_FOR_SNOW_LEOPARD |
2423 <NSTableViewDataSource,NSTableViewDelegate> | 2462 <NSTableViewDataSource,NSTableViewDelegate> |
2424 #endif | 2463 #endif |
5757 } | 5796 } |
5758 | 5797 |
5759 /* Internal common function to create containers and listboxes */ | 5798 /* Internal common function to create containers and listboxes */ |
5760 HWND _dw_cont_new(ULONG cid, int multi) | 5799 HWND _dw_cont_new(ULONG cid, int multi) |
5761 { | 5800 { |
5762 NSScrollView *scrollview = [[NSScrollView alloc] init]; | 5801 DWFocusRingScrollView *scrollview = [[DWFocusRingScrollView alloc] init]; |
5763 DWContainer *cont = [[DWContainer alloc] init]; | 5802 DWContainer *cont = [[DWContainer alloc] init]; |
5764 | 5803 |
5765 [cont setScrollview:scrollview]; | 5804 [cont setScrollview:scrollview]; |
5766 [scrollview setBorderType:NSBezelBorder]; | 5805 [scrollview setBorderType:NSBezelBorder]; |
5767 [scrollview setHasVerticalScroller:YES]; | 5806 [scrollview setHasVerticalScroller:YES]; |