Re: For Correct Redo Action Name: Undo Method must be Dedicated?
Re: For Correct Redo Action Name: Undo Method must be Dedicated?
- Subject: Re: For Correct Redo Action Name: Undo Method must be Dedicated?
- From: Jerry Krinock <email@hidden>
- Date: Mon, 14 Aug 2006 21:13:10 -0700
- Thread-topic: For Correct Redo Action Name: Undo Method must be Dedicated?
I received an off-list reply reminding me that I could use NSUndoManager
-isUndoing and -isRedoing to set a "context-sensitive" action name.
That would work, but seemed a little messy. However, it helped me to
understand what was going on. I've concluded that my original assertions
are correct, and, yes, a "dedicated" undo method for each action is one
solution. But it seemed cleaner to write one heavily-parameterized
"do/undo/redo-all" method. In my case, first argument of this method is an
enum Action, where
enum Action {
move,
add,
remove,
copy,
undoMove,
undoAdd,
undoRemove,
undoCopy
} ;
In the implementation, I switch on action to set appropriate undo actions
and undo action names. It's rather verbose, but I feel it's worth it in
this case.
I also wrote this summary, for future reference, since I believe it says a
few things that Apple's "Undo Architecture" document does not...
1. While an NSUndoManager is not undoing and not redoing, any invocations
(and action names) registered with it are placed on the undo stack. The
action names will appear in the menu as "Undo [whatever]".
2. While an NSUndoManager is undoing, any invocations (and action names)
registered with it get placed on the redo stack. The action names will
appear in the menu as "Redo [whatever]".
3. While an NSUndoManager is redoing, any invocations (and action names)
registered with it get placed on the undo stack. The action names will
appear in the menu as "Undo [whatever]".
So, in order for the menus to make sense, the action name set during the
three executions (do, undo and redo) of any given action (move, add, etc.)
should be the same.
_______________________________________________
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