Posted 27 July 2023, 1:55 am EST
- Updated 27 July 2023, 6:50 am EST
Hi,
You can create a custom command and register it with the command manager using commandManager.register() method. A command can be bound to keyboard keys using commandManager.setShortcutKey() method. In the execute() method of the custom command, the spread.focus(false) method can be utilized to move the focus out of spread sheet.
Please refer to the code snippet and attached sample.
//creates a custom command
let command = {
canUndo: false,
execute: function (context, options, isUndo) {
options.cmd = "focusOut";
context.focus(false);
return true;
}
};
let commandManager = spread.commandManager();
// registers the custom command with command manager
commandManager.register("focusOut", command);
// binds custom command with ctrl + m key
commandManager.setShortcutKey('focusOut', 77, true, false, false, false);
sample: https://jscodemine.grapecity.com/share/NpT35_E8Gkuq7lhNICQ-UA/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30&defaultOpen={"OpenedFileName"%3A["%2Findex.html"%2C"%2Fsrc%2Fapp.js"]%2C"ActiveFile"%3A"%2Fsrc%2Fapp.js"}
Please note that SpreadJS Designer does not support keyboard navigation with Tab key as it would conflict with the default behavior of Tab key in the spreadsheet. The feature to interact with designer ribbon with Alt key is currently in our product backlog. The internal tracking id for this is: SJS-11819
Please let us know if you still face any issues.
Doc reference
*commandManager.register():https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Commands.CommandManager#register
*commandManager.setShortcutKey():https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Commands.CommandManager#setshortcutkey
*spread.focus():https://www.grapecity.com/spreadjs/api/classes/GC.Spread.Sheets.Workbook#focus
Regards,
Chandan