Making the command undoable and redoable

Commands are not inherently undoable--you have to specifically create them that way. Commands are not undoable by default, to prevent users from trying to undo commands when this functionality hasn't been built in.

To make a command undoable, you need to:

    Serial undo means that commands are undone in the same order they were done. This order is guaranteed--that is, if a user selects the `Undo' option, the last executed undoable command will be undone. The Undo option is not enabled until an undoable command has been executed.
A command that is undoable should also be redoable. The Redo function is enabled for a command after it has already been undone. To support redoing the command, you should also implement the HandleRedo function. In TChangeColorCommand, HandleRedo is just like HandleDoBegin except that it doesn't need to save information required for undo--because the command has already been executed once, the HandleDoBegin function has already saved this information. The framework guarantees that HandleDoBegin is called before HandleDoUndo can be called, and that HandleDoUndo is called before HandleDoRedo can be called.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker