views:

68

answers:

2

Hi All, 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.

A: 

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.

smorgan
A: 

I had the very same problem: http://stackoverflow.com/questions/2984064/how-to-add-data-from-an-nstextfield-to-a-core-data-attribute-without-having-to-pr

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