Posted 6 May 2018, 11:15 am EST
Thanks Deepak for those work-arounds.
You will also need to handle sheet insertion via the context menu. Is there a way to call the “default” command within a custom command? For example, if I replace the command for inserting a sheet, I want to still call the standard command, otherwise I’ll have to implement a sheet name generator that mimics the behaviour of adding a sheet using the “+” button.
However, the following code doesn’t work:
let commandManager = spread.commandManager();
function insertSheet() {
// some custom logic here
commandManager.execute("gc.spread.contextMenu.insertSheet"); // this doesn't work
}
commandManager.register("insertSheet", {canUndo: false, execute: insertSheet});
function CustomMenuView() {
}
CustomMenuView.prototype = new GC.Spread.Sheets.ContextMenu.MenuView();
CustomMenuView.prototype.createMenuItemElement = function (menuItemData) {
let menuItemView = GC.Spread.Sheets.ContextMenu.MenuView.prototype.createMenuItemElement.call(this, menuItemData);
if (menuItemData.name === "gc.spread.insertSheet") {
menuItemData.command = "insertSheet";
}
return menuItemView;
};
spread.contextMenu.menuView = new CustomMenuView();