2

In my application I have an NSSearchField that is bound to an arraycontroller which performs searches as the user types.

The problem is that the search field never resigns firstresponder-status once it receives it.

What would be the cleanest way of resigning firstresponder status when the user presses Enter or clicks outside of the search field? If possible I would prefer to do as much work as possible in Interface Builder.

Christoffer
  • 25,035
  • 18
  • 53
  • 77

1 Answers1

10

[searchField.window makeFirstResponder:nil]

If you just want to get rid of the focus ring, you can disable it in the NIB.

If you want to resign first responder when the user clicks empty space in the window, you have to use a custom NSView as the window's content view and override mouseDown: to call the above method.

Francis McGrew
  • 7,264
  • 1
  • 33
  • 30