• 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: Focus ring around NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Focus ring around NSTextField


  • Subject: Re: Focus ring around NSTextField
  • From: Scott Anguish <email@hidden>
  • Date: Sun, 27 Oct 2002 17:30:58 -0500

On Sunday, October 27, 2002, at 05:52 AM, Peter Schols wrote:

Hi,

Is there a possibility not to draw the focus ring around an NSTextField?
Is there a way to modify the focus ring itself?

It must be possible.. Mail is doing it, and the rounded field that they're using is made up of a normal text field, with some images on either side.



Any pointers to method calls, examples or sample code is much appreciated!

Here's a whole mess of pointers, it gets less useful as it goes further down the list...

maybe Chuck Pisula or Ali Ozer or someone at Apple will pop in with the answer

NSColor seems to have a keyboardFocusIndicatorColor call..

NSView has this -(void)setKeyboardFocusRingNeedsDisplayInRect:(NSRect)rect;

I think setShowsFirstResponder: can be overriden in your custom text cell class and respond no... then you'd need to figure out how to implement the drawing in your cell that holds the NSTextFieldCell

this from the 10.2 release notes

In Mac OS X 10.1, a NSTextFieldCell in a control would draw its focus ring if its control was being edited. For complex controls with multiple text fields this caused the focus ring to be drawn many times, resulting in a dark focus ring without the desired soft edges. This has been fixed. NSTextFieldCell now checks its 'showsFirstResponder' attribute to determine if it should draw the focus ring when the control is being edited. If you notice that your focus rings don't show up anymore, you can call cell's setShowsFirstResponder: with a value of YES.


From the 10.1 release notes (very sparse info here)


Keyboard UI

10.1 brings the keyboard navigation feature of Cocoa back to life. Users can now use tab, shift-tab, and various control keys (user settable; see Preferences) to navigate between user interface elements. For instance, using the default settings, ctrl-F2 takes focus to the menu bar and ctrl-F5 takes focus to the toolbar. Note that by default, full keyboard navigation is disabled, and users can only tab between text elements and lists. Hitting ctrl-F1 enables full navigation.

As was the case before, for windows which have an initialFirstResponder set, the kit assumes there is a valid keyboard navigation loop and uses the existing loop. If you have windows with an initialFirstResponder in which you have added or deleted UI elements, the navigation might be messed up.

In windows without an initialFirstResponder, the kit will create a keyboard UI loop for you.

We support a way that custom controls can add a keyboard focus ring around text, graphics, and images. For instance, see keyboard focus in toolbars. This function sets a 'style' in the current graphics context in the current locked focus view which affects all rendering until the graphics state is restored.

typedef enum {
NSFocusRingOnly = 0,
NSFocusRingBelow = 1,
NSFocusRingAbove = 2
} NSFocusRingPlacement;

void NSSetFocusRingStyle(NSFocusRingPlacement placement);

The placement indicates how the focus ring will be drawn. Use NSFocusRingAbove to draw over an image, use NSFocusRingBelow to draw the focus ring under text, and use NSFocusRingOnly if you don't have an image or text. For the NSFocusRingOnly case, fill a shape to add the focus ring around the shape.

Note that the focus ring may actually be drawn outside the view but will be clipped to any clipping superview or the window content view.

Because the focus ring may be drawn outside the view, use the following NSView method to invalidate the area around the focus ring.

-(void)setKeyboardFocusRingNeedsDisplayInRect:(NSRect)rect;

Pass in the rectangle of the control or cell and it will be expanded and invalidated.




and NSView has a focusView... NSAccessibility might be useful to look at too

There is an example from WWDC that I could have sworn supported focus at the demo, but the demo code does' seem to (its available from ADC for reasons I don't fully understand)

perhaps this is being done using the cell drawing methods and they could be overridden... I wish I had a better answer for you, since I' interested in implementing a generic field just like in Mail.app for one of my apps..

From NSCell

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;

I'd expect a 'drawFocusFrame:inView:' or something simple to override


Not as much help as I'd have hoped.
_______________________________________________
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.

  • Follow-Ups:
    • [more coherent info] Re: Focus ring around NSTextField
      • From: Scott Anguish <email@hidden>
References: 
 >Focus ring around NSTextField (From: Peter Schols <email@hidden>)

  • Prev by Date: Re: Max arguments for NSTask?
  • Next by Date: Splash Screen
  • Previous by thread: Focus ring around NSTextField
  • Next by thread: [more coherent info] Re: Focus ring around NSTextField
  • Index(es):
    • Date
    • Thread