Posted 2 October 2018, 11:56 pm EST
I am trying to understand how undo/redo work to properly implement some custom commands.
According to the documentation http://help.grapecity.com/spread/SpreadSheets11/webframe.html#undo.html, if I understood property, custom command will send undo with Ctrl-Z.
I made a small sample to try, but undo is never called when using ctrl-z.
spread.commandManager().register('undo', {
canUndo: true,
execute: (context, options, isUndo) => {
if(isUndo) console.log('undo');
else console.log('do');
}
});
spread.commandManager().setShortcutKey('undo', GC.Spread.Commands.Key.a, true, false, false, false);
I read about undoManager but I am not ```
The default instance can be provided with spread ```
this.workbook.undoManager()
For this reason I tried expanding my example with this, but it still does not trigger the undo.
spread.commandManager().register('undo', {
canUndo: true,
execute: (context, options, isUndo) => {
if(isUndo) console.log('undo');
else console.log('do');
}
});
spread.commandManager().register('doundo', {
canUndo: false,
execute: (context, options, isUndo) => {
spread.undoManager().undo();
}
});
spread.commandManager().setShortcutKey('undo', GC.Spread.Commands.Key.a, true, false, false, false);
spread.commandManager().setShortcutKey('doundo', GC.Spread.Commands.Key.a, true, true, false, false);
Is it possible to have some more explanation on how undo/redo works?