Re: Drawing the focus ring
Re: Drawing the focus ring
- Subject: Re: Drawing the focus ring
- From: "Sean McBride" <email@hidden>
- Date: Tue, 21 Jun 2005 12:45:05 -0400
- Organization: Rogue Research
On 2005-06-13 01:19, Sam Wilkins said:
>I'm having a bit of a problem drawing the focus ring around a custom
>view I'm writing. I'm calling setFocusRingType: with
>NSFFocusRingExterior in my init method, and
>setKeyboardFocusRingNeedsDisplayInRect: with [self frame] at the end
>of my drawRect:, but I'm not having any luck. Any help would be
>appreciated.
I asked some months ago, and the best way is:
in your drawRect: do:
// Draw focus ring if this view is the first responder
if ([self isFirstResponder]) {
[NSGraphicsContext saveGraphicsState];
NSSetFocusRingStyle (NSFocusRingOnly);
[[NSBezierPath bezierPathWithRect:[self bounds]] fill];
[NSGraphicsContext restoreGraphicsState];
}
setKeyboardFocusRingNeedsDisplayInRect: should not be called in your
drawRect: just as setNeedsDisplay: should not be. I generally call:
[self setKeyboardFocusRingNeedsDisplayInRect:[self bounds]];
at the same times I call setNeedsDisplay:YES
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden