Package | org.robotlegs.utilities.undoablecommand |
Class | public class UndoableCommand |
Inheritance | UndoableCommand ![]() ![]() |
Property | Defined By | ||
---|---|---|---|
![]() | eventDispatcher : IEventDispatcher
Event bus to dispatch events on. | UndoableCommandBase | |
history : CommandHistory
Reference to the CommandHistory being used by this Command
| UndoableCommand |
Property | Defined By | ||
---|---|---|---|
![]() | hasExecuted : Boolean
Keeps track of whether this command has been executed,
to prevent undoing commands that have not been yet been executed. | UndoableCommandBase | |
isCancelled : Boolean = false | UndoableCommand |
Method | Defined By | ||
---|---|---|---|
UndoableCommand(doFunction:Function = null, undoFunction:Function = null) | UndoableCommand | ||
cancel():void
Call this function in your doExecute method to prevent this item from being added to the history stack. | UndoableCommand | ||
![]() | execute():void
Executes the command. | UndoableCommandBase | |
![]() | undo():void
Executes the undo function. | UndoableCommandBase |
Method | Defined By | ||
---|---|---|---|
doExecute():void [override]
Executes the command. | UndoableCommand | ||
undoExecute():void [override]
Override this function in your subclasses to implement the undo of the actions performed in doExecute(). | UndoableCommand |
history | property |
public var history:CommandHistory
Reference to the CommandHistory being used by this Command
isCancelled | property |
protected var isCancelled:Boolean = false
UndoableCommand | () | Constructor |
public function UndoableCommand(doFunction:Function = null, undoFunction:Function = null)
Parameters
doFunction:Function (default = null )
| |
undoFunction:Function (default = null )
|
cancel | () | method |
public function cancel():void
Call this function in your doExecute method to prevent this item from being added to the history stack. TODO: Throw an error if cancelling within a redo. Currently assumes if the cancel condition did not fire on the first run, they will pass on subsequent executions. This is faulty.
doExecute | () | method |
override protected function doExecute():void
Executes the command. Override this function in your subclasses to implement your command's actions. You may call cancel() at any point in this function to prevent it from being added to the history stack, but remember that execution does not stop when you call cancel and you will need to ensure the doExecute method did not actually make any changes. Ensure you call super.doExecute() at the end of your subclassed method. Note command is only automatically pushed to history once we try to execute this command Subclasses MUST override this function with the body of their command.
See also
undoExecute | () | method |
override protected function undoExecute():void
Override this function in your subclasses to implement the undo of the actions performed in doExecute(). Ensure you call super.undoExecute() at the end of your subclassed method. Subclasses must override this function. This function should undo whatever the doExecute command did.
Error — Prevents history corruption by throwing error if trying to undo this command and it's not at the top of the history (i.e. next to be undone).
|
See also