Лучший способ, которым я нашел способ остановить любой элемент управления от первого респондента при первом отображении окна, - это контроллер окна:
Swift 3:
class YourWindowController: NSWindowController {
override func windowDidLoad() {
super.windowDidLoad()
// Wait a frame before setting the first responder to be the window itself.
// We can't just set it right now, because if the first responder is set
// to the window now the system just interprets that as meaning that we
// want the default behavior where it automatically selects a view to be
// the first responder.
DispatchQueue.main.async {
window!.makeFirstResponder(nil)
}
}
}
Это грязно, и иногда, когда загружается окно, вы видите, что кольцо фокусировки начинает появляться на одном из элементов управления для одного кадра, но я пока не нашел лучшего способа.