Commit 860cd765 authored by Conor Shipp's avatar Conor Shipp Committed by Evan W. Patton

Added context menu items to enable and disable all blocks (#1353)

This commit adds two new items to the context menu of the blocks editor. The first one is "Enable All Blocks" which enables all blocks on the workspace. The second option is "Disable All Blocks" which disables all of the blocks on the workspace.

Resolves #1091
parent 027ee8a4
...@@ -89,6 +89,8 @@ Blockly.Msg.en.switch_language_to_english = { ...@@ -89,6 +89,8 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.DISABLE_GRID = 'Disable Workspace Grid'; Blockly.Msg.DISABLE_GRID = 'Disable Workspace Grid';
Blockly.Msg.ENABLE_SNAPPING = 'Enable Snap to Grid'; Blockly.Msg.ENABLE_SNAPPING = 'Enable Snap to Grid';
Blockly.Msg.DISABLE_SNAPPING = 'Disable Snap to Grid'; Blockly.Msg.DISABLE_SNAPPING = 'Disable Snap to Grid';
Blockly.Msg.DISABLE_ALL_BLOCKS = 'Disable All Blocks';
Blockly.Msg.ENABLE_ALL_BLOCKS = 'Enable All Blocks';
// Variable renaming. // Variable renaming.
Blockly.MSG_CHANGE_VALUE_TITLE = 'Change value:'; Blockly.MSG_CHANGE_VALUE_TITLE = 'Change value:';
......
...@@ -709,6 +709,32 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) { ...@@ -709,6 +709,32 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
arrangeOptionV.callback(opt_type); arrangeOptionV.callback(opt_type);
} }
// Enable all blocks
var enableAll = {enabled: true};
enableAll.text = Blockly.Msg.ENABLE_ALL_BLOCKS;
enableAll.callback = function() {
var allBlocks = Blockly.mainWorkspace.getAllBlocks();
Blockly.Events.setGroup(true);
for (var x = 0, block; block = allBlocks[x]; x++) {
block.setDisabled(false);
}
Blockly.Events.setGroup(false);
};
menuOptions.push(enableAll);
// Disable all blocks
var disableAll = {enabled: true};
disableAll.text = Blockly.Msg.DISABLE_ALL_BLOCKS;
disableAll.callback = function() {
var allBlocks = Blockly.mainWorkspace.getAllBlocks();
Blockly.Events.setGroup(true);
for (var x = 0, block; block = allBlocks[x]; x++) {
block.setDisabled(true);
}
Blockly.Events.setGroup(false);
};
menuOptions.push(disableAll);
// Retrieve from backpack option. // Retrieve from backpack option.
var backpackRetrieve = {enabled: true}; var backpackRetrieve = {enabled: true};
backpackRetrieve.text = Blockly.Msg.BACKPACK_GET + " (" + backpackRetrieve.text = Blockly.Msg.BACKPACK_GET + " (" +
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment