mirror of
https://github.com/google/blockly.git
synced 2026-01-10 10:27:08 +01:00
Add hook for custom context menus on the workspace
This commit is contained in:
@@ -268,6 +268,13 @@ Blockly.WorkspaceSvg.prototype.flyoutButtonCallbacks_ = {};
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.toolboxCategoryCallbacks_ = {};
|
||||
|
||||
/**
|
||||
* Developers may define this function to add custom menu options to the
|
||||
* workspace's context menu or edit the workspace-created set of menu options.
|
||||
* @param {!Array.<!Object>} options List of menu options to add to.
|
||||
*/
|
||||
Blockly.WorkspaceSvg.prototype.configureContextMenu = null;
|
||||
|
||||
/**
|
||||
* In a flyout, the target workspace where blocks should be placed after a drag.
|
||||
* Otherwise null.
|
||||
@@ -1310,6 +1317,11 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
|
||||
};
|
||||
menuOptions.push(deleteOption);
|
||||
|
||||
// Allow the developer to add or modify menuOptions.
|
||||
if (this.configureContextMenu) {
|
||||
this.configureContextMenu(menuOptions);
|
||||
}
|
||||
|
||||
Blockly.ContextMenu.show(e, menuOptions, this.RTL);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user