4
votes

I have an NSTableView working correctly except when I'm editing one of the table items. If the user is still in edit mode, and it presses the Sheet OK button, the tableiew doesn't update.

How do I force the tableview to commit the changes when the user press the ok button (closesheet).

Also, how do I handle the ESC Key to cancel the editing?

Sorry if the questions looks absurd, but I've been only on developing on Mac for a month.

2

2 Answers

3
votes

You should be able to call [sheet makeFirstResponder:sheet], where sheet is the sheet you are about to close. That will switch first responder status away from the text field, which will cause it to commit the in-progress edit.

1
votes

I had the very same problem: How to add data from an NSTextField to a Core Data Attribute without having to press Return or Tab after editing the TextField?

There seem to be different solutions. If you use bindings to connect the NSTextField of your edit sheet to the ArrayController, you could check „continously update value“ in the TextFields value binding in Interface Builder.

Other solutions are explained very well in this blogpost at Red Sweater Blog: http://www.red-sweater.com/blog/229/stay-responsive