mxUndoManager undo() does not work after applying layot (for exampel mxCircleLayout). What can be the problem? PS: I'm using 0 size for unlimited history.

asked 21 Nov '12, 05:29

Kravets%20Vladimir's gravatar image

Kravets Vladimir
35115
accept rate: 0%

Could you show use the code you used please?

(21 Nov '12, 05:30) David

mxUndoManager undoManager = new mxUndoManager(0);

var listener = function(sender, evt) {

undoManager.undoableEditHappened(evt.getProperty('edit'));

};

graph.getModel().addListener(mxEvent.UNDO, listener);

graph.getView().addListener(mxEvent.UNDO, listener);

...

graph.getModel().beginUpdate();

try {

graph.getModel().beginUpdate();

var layout = new mxCircleLayout(graph);

layout.execute(graph.getDefaultParent());

} catch (e) {

throw e;

}

finally {

var morph = new mxMorphing(graph);

morph.addListener(mxEvent.DONE, function() {

graph.getModel().endUpdate();

});

morph.startAnimation();

}

...

undoManager.undo();

(21 Nov '12, 05:39) Kravets Vladimir

Remove the graph.getModel().beginUpdate() inside the try block.

link

answered 21 Nov '12, 08:10

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

It does not help, I accidentally added it when preparing an example.

And it looks like that undo() starts to work after some minutes (or mb dozens minutes) after layout was applied.

(21 Nov '12, 08:23) Kravets Vladimir

Looks like there is some background process starts on layout applying and undo starts to work after this process ends his work.

(21 Nov '12, 08:25) Kravets Vladimir

Can't reproduce, works for me. I've emailed an example.

(21 Nov '12, 08:39) Gaudenz

Thank you for your active support. Your example works correctly, but it seems that something else has an impact, but I can not understand what is it. It seems that time after which undo manager starts to work dependends on the number of items in graph and the type of layout.

(21 Nov '12, 09:03) Kravets Vladimir

Tried to call undo() via setTimeout after layout applying and it works fine, so the real problem was that key press event is not fired after layout applying. I'm using mxKeyHandler: keyHandler.bindKey(keyCode, function(evt) { ... }

Tomorrow, I'll try to understand why this is so.

(21 Nov '12, 09:35) Kravets Vladimir

Hey, can you please email me Gaudenz's example? Thanks a lot.

(29 Jan '13, 10:51) walolinux
showing 5 of 6 show all
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×228
×39
×28
×1

Asked: 21 Nov '12, 05:29

Seen: 1,663 times

Last updated: 29 Jan '13, 10:51