Posted 13 April 2022, 8:14 am EST
Hi David,
This is expected our logs will only print in the console if our custom command gets executed so for customRedo command logs only gets printed if we hit Ctrl + y (only ctrl+y not cmd+y since we not pass the meta argument to true while using setShortcut key method) command and then if we hit ctrl +z our custom undo transaction part will be executed.
for assigning custom commands on cmd key combination you may refer to the following code snippet.
spread.commandManager().setShortcutKey('navigationPageUp',
GC.Spread.Commands.Key.up, false, false, false, true);
setShortCutKey: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Commands.CommandManager~setShortcutKey.html?highlight=meta%2C
In the screenshot what happens is when you undo using the keys the builtin command gets executed and when using the button the undo method executed and undo the actions internally.
So if you want to get the undo stack when user hit undo using key then you need to override the builtin undo command and if you are calling the undo on button then you just need to get undo stack before calling the methods please refer to the following code snippet and updated that explains the same.
GC.Spread.Sheets.Commands.undo.execute =function(){
logUndoStack("fromUndo")
return old.apply(this,arguments)
};
let oldRedo = GC.Spread.Sheets.Commands.redo.execute;
GC.Spread.Sheets.Commands.redo.execute =function(){
logRedoStack("fromRedo");
return oldRedo.apply(this,arguments)
};
sample: https://jscodemine.grapecity.com/share/EkDe4ZxVHkeOIDQad37beA/
Regards,
Avinash