How to remove focus on NSTextField if I'm not focus in the textField?
I have a NSTextField and I set the Action: Sent On End Editing. After clicking the textField, the FOCUS will always in my NSTextField when I click other places on the view. Furthermore, I use makeFirstResponder and resignFirstResponder but all in vain. Any idea?
@IBAction func endOfEditing(sender: NSTextField) {
view.window?.makeFirstResponder(nil)
view.window?.resignFirstResponder()
}
For illustration, the FOCUS will always be in textField no matter where I pressed. (Even when I pressed the button)
How can I remove the focus when I click outside the textField?
view.window?
. You might want to try using the name of your ViewController class, however once again I am very new to Swift. Also, I'm not too sure if I understand your question correctly. Maybe clarify how you want the NSTextField to be focused, what that means exactly? – lucapresignFirstResponder()
on your text view – Leesender.window?.resignFirstResponder()
but in vain .. – Willjaysender.resignFirstResponder()
– Leo Dabus