Exception: "NSWindow: -_oldFirstResponderBeforeBecoming is not a valid message outside the implementation of the responder -becomeFirstResponder." However, according to the stack trace, the message is called from becomeFirstResponder
, so I don't know what I'm doing wrong. This is an intermittent error.
The user presses a key command sequence that calls up a menu item that sends a message to the key window controller, which tells the search field in the window to become the first responder.
Here's the total stack trace ::
[NSException raise:format:]
[NSWindow _oldFirstResponderBeforeBecoming]
[NSSearchField becomeFirstResponder]
[MyWindowController focusSearchField]
[NSApplication sendAction:to:from:]
[NSMenu performKeyEquivalent:]
Implementing a window controller action is very simple:
public var searchField: NSSearchField?
@IBAction public func focusSearchField(sender: AnyObject) {
searchField?.becomeFirstResponder()
}
Thanks for any help.
source
share