• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing the focus ring
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Drawing the focus ring (From: Sam Wilkins <email@hidden>)

  • Prev by Date: Re: Keyed encoding
  • Next by Date: Re: NSTreeController - please help, can't see the forest for the tree controller
  • Previous by thread: Re: Drawing the focus ring
  • Next by thread: Warning: critical Core Data documentation flaw
  • Index(es):
    • Date
    • Thread