Re: Undo and Redo
- From: "Jonathon Jongsma" <jonathon jongsma gmail com>
- To: "Arthur Maciel" <arthurmaciel gmail com>
- Cc: gtkmm-list gnome org
- Subject: Re: Undo and Redo
- Date: Mon, 5 Feb 2007 08:29:35 -0600
On 2/5/07, Arthur Maciel <arthurmaciel gmail com> wrote:
Thanks,
Bernib.
But if the user cuts some selection from a treeview and set the focus to
another treeview, when he undo'es, how could I know where the cut
information belongs to?
Regards,
Arthur
Generally, undo/redo functionality is done with two stacks: an undo
stack and a redo stack. each stack holds a list of objects that
describe the action that can be undone (or re-done). When the user
clicks the 'undo' button, you pop the top item off the undo stack,
perform the action, and push it onto the redo stack.
You'd have to store enough information to make the action reversible.
Generally this is application specific, so it's going to be different
for each application. For example, you might create a UndoableAction
class that stores the action type, maybe a pointer to the widget that
the action was applied to, and any other data necessary to re-do the
action. So in the specific case you describe, you might create an
UndoableAction object with a "REMOVE" action, applied to TreeViewA,
with data xyz.
Anyway, those are just some ideas off the top of my head. There are
probably better ways to do the UndoableAction than the simplistic
implementation I mentioned above. You could do a google search for
something like "undo manager" to get more inspiration.
Hope that helps.
--
jonner
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]