Hi, dear Gojser, I have encountered this problem:
Redo triggered by Ctrl-Y works, but calling diagram.undoManager.redo() not work.
My code are as following:
diagramUndo = () => {
if (this.canvas && this.canvas.undoManager.canUndo()) {
this.canvas.undoManager.undo()
}
}
diagramRedo = () => {
if (this.canvas && this.canvas.undoManager.canRedo()) {
this.canvas.undoManager.redo()
}
}
diagramDeleteSelection = () => {
if (this.canvas && this.canvas.canDeleteSelection) {
this.canvas.deleteSelection()
}
}
Have I missed something to call this API?
walter
March 2, 2021, 1:03pm
2
You are missing parentheses in your call to CommandHandler.canDeleteSelection .
Otherwise your code looks OK, assuming this.canvas
returns a Diagram . When you step through the code, what happens?
Hi, Walter, thanks for pointing out the missing parentheses.
Here is what report in ‘canRedo()’:
And as you know the result is false.
But I have inspected the ‘undoManager’ and it has values of its ‘transactionToRedo’ and ‘transactionToUndo’.
walter
March 3, 2021, 3:16am
4
I cannot explain that. Maybe the state changed between when you were stepping through it and you looked at the UndoManager. Or maybe the debugger caused the state to change. Not likely, but that’s all I can guess.