On Feb 16, 2014, at 9:34 AM, Trygve Inda wrote:

> I have an NSTableView with several columns bound to an NSArrayController
> which manages the array of my custom objects.
> 
> Undo of course works while editing a cell in the NSTableView, but once the
> edit is complete, I need to manage it myself.
> 
> How is the best way to do this?
> 
> I need to know the original contents of the cell (property in my object) so
> do I need to use controlTextDidBeginEditing, save the value somewhere, then
> in controlTextDidEndEditing, if they are different, push the change onto the
> undo stack?
> 
> Since the table uses bindings, the setting of the property is handed by the
> binding system.

With bindings, the best choice, IMHO, is to handle undo in custom setters. You 
will get easy redo support this way, as well. Depending on when you would make 
something un-undoable would determine who will maintain the NSUndoManager 
instance.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to