Re: Focus ring around NSTableView
Re: Focus ring around NSTableView
On Mon, Mar 25, 2002 at 01:43:44PM -0800, Steven Frank wrote:
>
I have a window with two NSTableViews. Currently the only indication
>
the OS provides of which one is "active" is that (if it has a selection)
>
the selection appears in a more saturated color than the "inactive" one.
>
>
I'd like a standard system focus ring to appear around the "active" one,
>
as the user switches between them. What's the best way to achieve this?
Subclass (or pose as) NSScrollView and add:
- (void)drawRect:(NSRect)rect {
[super drawRect: rect];
if ([[self window] isKeyWindow]) {
NSResponder *resp = [[self window] firstResponder];
if ([resp isKindOfClass: [NSView class]] && [(NSView *)resp isDescendantOf: self]) { // [sic]
NSSetFocusRingStyle(NSFocusRingOnly);
NSRectFill(rect);
}
}
[self setKeyboardFocusRingNeedsDisplayInRect:rect];
}
That's not super-efficient but I've used it in several applications
and it seems to perform OK.
--
=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.