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

Added context menu items to show and hide all comments

This commit adds two new options to the block editor's context menu to
show and hide all the comments on the workspace.
Resolves #1422
parent f4a2749a
......@@ -90,6 +90,8 @@ Blockly.Msg.en.switch_language_to_english = {
Blockly.Msg.DISABLE_SNAPPING = 'Disable Snap to Grid';
Blockly.Msg.DISABLE_ALL_BLOCKS = 'Disable All Blocks';
Blockly.Msg.ENABLE_ALL_BLOCKS = 'Enable All Blocks';
Blockly.Msg.HIDE_ALL_COMMENTS = 'Hide All Comments';
Blockly.Msg.SHOW_ALL_COMMENTS = 'Show All Comments';
// Variable renaming.
Blockly.MSG_CHANGE_VALUE_TITLE = 'Change value:';
......
......@@ -740,6 +740,36 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
};
menuOptions.push(disableAll);
// Show all comments
var showAll = {enabled: true};
showAll.text = Blockly.Msg.SHOW_ALL_COMMENTS;
showAll.callback = function() {
var allBlocks = Blockly.mainWorkspace.getAllBlocks();
Blockly.Events.setGroup(true);
for (var x = 0, block; block = allBlocks[x]; x++) {
if (block.comment != null) {
block.comment.setVisible(true);
}
}
Blockly.Events.setGroup(false);
};
menuOptions.push(showAll);
// Hide all comments
var hideAll = {enabled: true};
hideAll.text = Blockly.Msg.HIDE_ALL_COMMENTS;
hideAll.callback = function() {
var allBlocks = Blockly.mainWorkspace.getAllBlocks();
Blockly.Events.setGroup(true);
for (var x = 0, block; block = allBlocks[x]; x++) {
if (block.comment != null) {
block.comment.setVisible(false);
}
}
Blockly.Events.setGroup(false);
};
menuOptions.push(hideAll);
// Retrieve from backpack option.
var backpackRetrieve = {enabled: true};
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