Re: FocusRing for view inside an NSScrollView ?
Re: FocusRing for view inside an NSScrollView ?
- Subject: Re: FocusRing for view inside an NSScrollView ?
- From: Brock Brandenberg <email@hidden>
- Date: Sun, 06 Apr 2003 18:07:36 -0500
>
Would anyone know how to draw a focus ring inside an NSScrollView ?
>
>
(Which is necessary when the view's enclosing NSScrollView is up against the
>
window edge(s).)
>
>
Example: ProjectBuilder's Frames and Variable views in the Debug window.
Here's one way to draw it on the document inside the scroll view, if that's
close enough to what you're after.
Draw the focus ring using something like this at the end of your NSView
subclass drawRect method:
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle( NSFocusRingAbove );
[[NSColor keyboardFocusIndicatorColor] set];
NSFrameRect( [self visibleRect] );
[NSGraphicsContext restoreGraphicsState];
And in order to keep the remnants of the focus ring from staying around when
you scroll the view, set setCopiesOnScroll: of the NSClipView to NO. You can
easily get the enclosing NSClipView using the following method in a category
of NSView (or by inserting the code elsewhere):
-(NSView *)superviewOfClass:(Class)aClass
{
NSView *result = self;
while( result = [result superview] )
{
if( [result isKindOfClass:aClass] )
return result;
}
return nil;
}
Note that you will no longer be taking advantage of the blitting when
scrolling, but your view will now have a focus indicator that stays put with
the visible rect.
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
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.