Paul Linsay
Paul Linsay

Reputation: 459

NSToolbarItem Highlights When It Shouldn't

I have strange behavior of NSToolbarItems that are in the toolbar of an NSPanel (Utility Panel) that's an inspector panel. When the panel first displays the three items are all OK

Toolbar when it first displays

As soon as I click on any of the items the left hand item is highlighted by a blue box.

Toolbar with blue highlight around first item

The blue highlight is independent of the image that's used for the NSToolbarItem and is always around the left hand image. It never goes away after the first click.

What's causing the highlight and how do I make it go away?

Thanks--

Upvotes: 0

Views: 320

Answers (1)

Ken Thomases
Ken Thomases

Reputation: 90641

That's the focus ring. It shows when the panel is made key (because of the click) and indicates which control will respond to keyboard events, like pressing the Space key. It would presumably move around among the controls in the window as you press Tab or Shift-Tab.

If you have any text fields or the like in your panel which take focus on a click, then clicking on one of those would presumably remove the focus ring from the toolbar item and put it on the text field.

You shouldn't view this as some big problem. However, if you really want to change it, you can make another view the first responder (focused view) to make the toolbar item not have focus.

You can set the initialFirstResponder of your window and/or your tab items. (I assume the toolbar items are switching among the tabs of a tabless tab view.)

Alternatively, you can make the window its own first responder by doing [window makeFirstResponder:nil]. Or you can make any specific view the first responder by doing if ([view acceptsFirstResponder]) [view.window makeFirstResponder:view];.

Upvotes: 1

Related Questions