UndoManager setActionNames


Graham Cox
 

The action name is part of the “view” layer in model-controller-view architecture. But most of the actual undoable ’stuff’ is in the model.

So I usually set the action name at the top level action method that responds to the original command, even if that burrows down and changes a bunch of stuff in the model. That works fine, because the Undo Manager itself keeps the same action name across undo/redo actions even if it doesn’t directly invoke the original action method for redo. This works fine as long as your model doesn’t also try messing with the action name - just keep that in the view layer.

—Graham

On 5 Jul 2020, at 5:07 pm, Arved von Brasch via Cocoa-dev <cocoa-dev@lists.apple.com> wrote:

Hi list,

Where’s the best place to intercept undo/redo actions to edit the action name (’setActionName()’) for the UndoManager in a CoreData application? In particular, when a particular entity’s attribute's change. Obviously, I want to do this so that when the user edits something, the menu name is more descriptive than just “Undo”/“Redo”.

Easiest, in terms of implementation, seems to be in the NSManagedObject subclass by means of an observer on the attribute. However, conceptually, it would make more sense to handle it in the NSArrayController or, maybe the NSTableView or other NSView object where the attribute is edited directly.

Just wondering where others have settled for best practice.

Kind regards,
Arved
_______________________________________________

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/graham.cox%40bigpond.com

This email sent to graham.cox@bigpond.com