Re: Focus ring around NSTableView
Re: Focus ring around NSTableView
- Subject: Re: Focus ring around NSTableView
- From: Steven Frank <email@hidden>
- Date: Mon, 25 Mar 2002 18:16:44 -0800
On Monday, March 25, 2002, at 02:16 PM, Nicholas Riley wrote:
On Mon, Mar 25, 2002 at 01:43:44PM -0800, Steven Frank wrote:
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.
Thank you! This works, but it does seem to incur a bit of a penalty.
It gets called every time the tableview is scrolled, selection changes,
etc, and as a result, the app is noticeably slower when scrolling
through the table than without it.
Any suggestions on how this could be improved?
Steven
_______________________________________________
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.