To enable undo and redo, call the setUndoEnabled method. When undo is enabled, the control records users actions and allows undoing them later. The records are stored in a list, and can be undone consecutively by calling the undo method of the Schedule class. An action that has been undone can be redone by calling the redo method. You can enable or disable UI elements that undo or redo commands by inspecting the result of the getCanUndo and getCanRedo methods.
The control also runs and saves in the undo history AddItemCommand and RemoveItemCommand commands when items are programmatically added or removed from the Items collection of the Schedule. No other changes are recorded automatically when done from code. If support for undo/redo of such changes is required, they must be done through the executeCommand method.
To undo changes of Item properties, create a ChangeItemCommand instance before setting the item properties, and call executeCommand afterwards. Any other types of undoable changes can be implemented by deriving from the Command class and overriding its execute, undo and redo methods.
Note |
---|
Changes made to the schedule during in-place editing or creation of an item while Undo/Redo is enabled are not supported and will usually result in broken undo consistency or errors. Any modifications to the schedule should be performed before the in-place operation has begun or after it has ended. |