Cocoa: How to prevent NSSearchField from the toolbar to get the first response?

If there is an NSSearchField in the toolbar, it automatically becomes the first responder when you press the TAB key in the window. How can I prevent this? That is, to get the search field to refuse the first responder?

+4
source share
1 answer

If you are using Xcode 4.3.2, open the XIB file, double-click an item in the toolbar to select NSSearchField (NSToolbarItem is selected with one click). In the Attribute Inspector, check the box next to "Unsubscribe from the first responder" and Bob your uncle.

The trick here is that NSToolbarItem cannot refuse the first responder as a whole. However, the NSSearchField (whose ancestor is NSToolbarItem) may refuse.

0
source

Source: https://habr.com/ru/post/1414492/


All Articles