views:

145

answers:

1

I have a Sketching app done in all HTML5 and Javascript, and I was wondering how I would create an Undo Button, so you could undo the last thing you drew. Any idea? Thanks!

+4  A: 

You have to store all modifications in a datastructure. Then you can delete the latest modification if the user want to undo it. Then you repaint all drawing operations from your datastructure again.

Jonas
Please see http://whiffdoc.appspot.com/tests/schema/diagram for an example of how to do this -- in this case by storing a JSON data structure representing the canvas information in an invisible DIV element. (follow link on page to source)
Aaron Watters