NSTextField: end editing when user clicks outside of the text field
问题 I have an NSTextField that I'm setting editable depending on a user action. I'd like to end editing when the user clicks anywhere outside of the text field inside the window. Seems simple, but I could not get this to work. I implemented controlTextDidEndEditing and textDidEndEditing , but no luck, especially when I click on a user interface element that does not accept the first responder status. 回答1: Every NSEvent is pass through NSWindow's sendEvent: method. You can create a custom NSWindow