Harris
Harris

Reputation: 3

How to merge multiple steps into one undo / redo?

I use mxGraph to make an editor. When the user clicks a button once, I need to perform many steps in the graph (such as moving the position of some nodes, adding or deleting some nodes, and modifying the properties of some nodes).

Generally, I can use mxModel.setValue (), mxGraph.removeCells () to complete one operation, but the user needs to press ctrl + z multiple times to restore the original state of the graph.

How to merge any number of operations into one operation and restore the state of the entire graph with one undo / redo?

Upvotes: 0

Views: 589

Answers (1)

Marco
Marco

Reputation: 256

I don't know if this is what you are looking for, but if everything you do between one model.beginUpdate() and a model.endUpdate() belongs to the same "undo" action. By calling the mxUndoManager.undo once you should be able to undo all of them at once...

Upvotes: 2

Related Questions