general undo methods?
martin at materiaprima.fsnet.co.uk
Sat Feb 19 03:49:53 EST 2005
> > On Feb 18, 2005, at 3:53 PM, Richard Gaskin wrote:
> >> Any of you have pointers to general methods for implemening undo
> >> across an app?
>The general method is to atomize your code so that every action the user
>can do generates undo code stored in a queue, which is then invoked when
>Undo is selected.
The only time I did this seriously was a while back and in Hypercard. I had
a specialised multimedia authoring environment for teaching purposes that
(among other things) implemented a custom interface to addColor. I used the
approach you describe above, but instead of storing state information, I
stored a statement that could be executed, using Do, which would reverse
the action in question. So for example if the user created a rectangle, the
undo list would contain something to the effect of:
delete graphic "grcname"
# (I forget the actual syntax now that it no longer matters)
It worked well, and allowed the actual undo handler to be very short and
very dumb. As has been noted however, different types of undo action may
require a range of strategies.
A snack for thought,
More information about the Use-livecode