Re: Focus ring around NSTableView
Re: Focus ring around NSTableView
Yup, I was drawing way too much. Here's a much better version:
@interface NJRScrollView : NSScrollView {
BOOL shouldDrawFocusRing;
NSResponder *lastResp;
}
@implementation NJRScrollView
- (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]); // [sic]
lastResp = resp;
[self setKeyboardFocusRingNeedsDisplayInRect: [self bounds]];
return YES;
}
- (void)drawRect:(NSRect)rect {
[super drawRect: rect];
NSLog(@"%@ drawing focus ring? %hd", self, shouldDrawFocusRing);
if (shouldDrawFocusRing) {
NSSetFocusRingStyle(NSFocusRingOnly);
NSRectFill(rect);
}
}
Remove the NSLog when you're satisfied that it isn't drawing too much...
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.