NSTextField and FirstResponder
I am developing a cocoa application that has a main window and several panel windows.
I need to autosave some text on a NSTextField
(which is on a panel window) when user leaves the textfield by clicking the main window etc. so far I have tried out by implementing resignFirstResponder on a NSTextField
subclass,however if I click on another textfield on the same window "resignFirstResponder" gets triggered but if I just click on somewhere empty on my main window it does not get triggered. ( NSTextField
loses the blue focus though)
I need to capture this event the NSTextField
loses the focus ring to save the uncommitted changes . Any pointers would be highly appreciated.
This text field is on NSTableCellView
使用[[NSApp mainWindow] resignFirstResponder];
How about using the NStextfield's action sent on end editing
Then simply right-click-drag to an object (or FirstResponder) in your Xib file and connect it to a method. It should now run this method when you end the editing (deselect, Enter or Tab).
链接地址: http://www.djcxy.com/p/85248.html