0

I have a view with multiple NSImageViews. How can I determine which NSImageView is highlighted when selected by the user? The isHighlighted property is always the same.

  • What do you mean by "highlighted when selected by the user"? Are the image views in a container view, like a collection view or table view, and you're referring to whether they are selected? Or are they editable and have focus and show a focus ring? – Ken Thomases Aug 23 '18 at 19:08
  • I'm referring to the focus ring –  Aug 23 '18 at 20:31

1 Answers1

0

To determine if any view has focus, you check if it is its window's firstResponder:

if (someView.window.firstResponder == someView)
    ...

There's a complication with text fields, because they use another object as a field editor, but that's not relevant for image views.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154