Page 1 of 1

What kinds of process can be part of an undo group?

Posted: Wed Dec 12, 2007 1:56 pm
by martindholmes
I noticed from this post:

<http://www.trichview.com/forums/viewtop ... light=undo>

that "direct assignment to StyleNo cannot be undone". I'm trying to create systems for undoing complex sequences of actions, so I'd like to know exactly what actions can be part of an UndoGroup, and which can't. For instance, I have an action which:
  • deletes an item in a TRichViewEdit
    creates a new style for another item, and applies it (by directly assigning the style number)
    repeats the above step for zero or more preceding items
I'd really like to undo this action with a GroupUndo, but it doesn't seem to be working, and I think it's because some of the actions above can't be part of an undo group. Is there any way I could make undo work in this situation?

Cheers,
Martin[/code]

Posted: Wed Dec 12, 2007 4:06 pm
by Sergey Tkachenko
May be the simplest way is to use standard editing operation? To select item and delete selection, to select items and apply new style?
These operations can be undone (except for adding new style to the collection, this operation is not undoable yet)

Posted: Wed Dec 12, 2007 9:07 pm
by martindholmes
Unfortunately, this almost always involves adding new styles to the collection.

Undo is such a messy business, eh?

I guess I'll have to try and store enough information to re-create the previous state of the document, by taking actions instead of undoing them. If I intercept the Undo command when I see that it's rvutCustom, and undertake my own undo actions, how do I remove that undo item from the undo list?

Cheers,
Martin

Posted: Thu Dec 13, 2007 4:23 pm
by Sergey Tkachenko
It's possible to create undo class for addition in style collections.
But, other operations may add styles as well, and it would be not simple to remove styles added only be certain operations.
I do not think this is a big problem, because unused styles can be deleted by DeleteUnusedStyles method.