new UndoAction(description)
Creates a new action item.
Parameters:
| Name | Type | Description |
|---|---|---|
description |
string | A human-readable description of this item. |
Example
class MyPropertyUndoItem extends PD.UndoAction {
constructor(host_object, oldValue, newValue) {
const description = 'My property changed from \'' + oldValue.toString() + '\' to \'' + newValue.toString() + '\'';
super(description);
this.hostObject = host_object;
this.oldValue = oldValue;
this.newValue = newValue;
};
undo(undoManager) {
if (this.hostObject) {
this.hostObject.setMyProperty(this.oldValue);
undoManager.rebuildModel();
}
};
redo(undoManager) {
if (this.hostObject) {
this.hostObject.setMyProperty(this.newValue);
undoManager.rebuildModel();
}
};
};
Methods
-
elapsedTime()
-
Retrieves the elapsed time since value was last updated, in milliseconds.
Returns:
Returns the elapsed time in milliseconds.
- Type
- number
-
redo(undoManager)
-
Redo the action defined by this action item.
Parameters:
Name Type Description undoManagerUndoManager The undo manager that invoked this action.
-
undo(undoManager)
-
Undo the action defined by this action item.
Parameters:
Name Type Description undoManagerUndoManager The undo manager that invoked this action.