Re: Undo group action name lost in drag operation
Re: Undo group action name lost in drag operation
- Subject: Re: Undo group action name lost in drag operation
- From: Shaun Wexler <email@hidden>
- Date: Tue, 5 Oct 2004 07:46:50 -0700
On Oct 5, 2004, at 6:33 AM, Gabriele de Simone wrote:
In response to a copy-on-drop operation in a NSTableView, I add a
number of elements to my model. To my great pleasure I noticed that
whatever Cocoa class was processing the drag operation for me was
automatically beginning and ending an undo group around my handler
(tableView:acceptDrop:row:dropOperation:).
Enlightened by this discovery, I set an action name at the end of my
insertions ("Add Items"), and sure enough this action name shows up
under the Edit menu as "Undo Add Items". The problems begin when you
undo that operation. The action name is lost, and the Redo menu item
name takes the name of the last nested action of the undo group.
Now, I did find the following workaround, which basically tells my
model objects *not* to set the action name if an undo group is open...
if ([undoManager groupingLevel == 0) {
[undoManager setActionName:@"something"];
}
...but I am interested in knowing whether I am ignoring some basic
knowledge on undo grouping action names. A search for "undo group
action name lost" brought up nothing on CocoaBuilder.
It's best to set your action name in your controller class, in the
action method, etc. In your case where the model is handling the
drag/drop, it's okay to set the action name AFTER the drop is
completed. You definitely don't want to set action names for the
individual array accessor methods in the model. I create a separate
API for undoable model actions in the model itself, which set the
action name. Your undo invocation should call back into the array
accessors, not the separate API.
--
Shaun Wexler
MacFOH
http://www.macfoh.com
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden