Undoing an Edit
Critical to any kind of editing is the ability to back out of a change that had unintended or undesirable effects. Fortunately, controller-based cuts and pastes can be undone with some fairly simple calls.
How do I do that?
UndoableQTEditor builds on the original
BasicQTEditor by adding an
“undo” menu item. The
doUndo( ) method it calls has an utterly trivial
implementation:
public void doUndo( ) throws QTException {
controller.undo( );
}Note
Compile and run this example with ant run-ch03-undoableqteditor.
What just happened?
With a simple call to MovieController.undo()
, the program gained the ability to undo
a cut or paste, or any other destructive change made through the
controller.
What about...
...multiple undoes? Or redoes? Ah, there’s the rub. Hit undo again and the cut or paste is redone, in effect undoing the undo.
Sadly, this is your dad’s “undo”...the undo from back in 1990, when a single level of undo was a pretty cool thing. Today, when users expect to perform multiple destructive actions with impunity, it’s not too impressive.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access