Skip navigation.
 
mlStrange behavior when drawing a focus ring
FROM : Eric Morand
DATE : Mon Jun 05 23:54:53 2006

Hi guys,

I've created a subclass of NSButton (and its associated NSButtonCell) 
and I'm encountering a strange problem with the focus ring. This 
problem has already been talked in this list with no solution found.

Here is how I draw my focus ring if the drawInterior... method of my 
custom cell :



- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)
controlView
{
   NSBezierPath * path = nil;
   
   cellFrame = NSInsetRect(cellFrame, 0.5, 0.5);
   
   path = [NSBezierPath bezierPathWithOvalInRect:cellFrame];
   
   // Some drawing here...

   if ( [self showsFirstResponder] )
   {
       [NSGraphicsContext saveGraphicsState];
       
       NSSetFocusRingStyle(NSFocusRingOnly);
       [path fill];
       
       [NSGraphicsContext restoreGraphicsState];
   }
}



Everything works fine, the focus rings draws perfectly when I loop 
through my buttons with Tab. But, when I press the button while it is 
the first responder (when the focus ring is drawn around the button), 
it is like the focus ring is drawn again above itself...and it looks 
ugly !

Am i doing something wrong in my code ? Note that my custom button 
returns NO to isOpaque (since it draws some of its parts with alpha).



Thanks,


Eric.

Related mailsAuthorDate
No related mails found.