The simplest way to do this is to assign a delegate for your window and respond to NSWindow
's -windowShouldClose: delegate method. In it, invoke -makeFirstResponder: to make the window itself the first responder, noting the BOOL
answer it gives. You should return whatever -makeFirstResponder:
answers as the answer to the delegate ...ShouldClose:
message since it may not be able to end editing / resign first responder. Assuming it's successful, it'll end editing and trigger whatever action / bindings machinery you set up prior to actually closing. This works because NSTableView
and the views it uses in view-based mode are subclasses of NSControl
and automatically handles the responder status changes by ending editing, etc. Hope this helps.
End Editing on NSTableView (View Based)
-
14-06-2023 - |
Вопрос
When a user is mid-editing a textfield on a tableview and decides to click the close button for the window, the changes he/she made does not get saved. How can I force a tableview (view based) to end editing (not abort editing) ?
Решение
Не связан с StackOverflow