Skip to content
Permalink
Browse files

Move "Empty Backpack" menu item to Backpack menu

  • Loading branch information...
ZhengCornell authored and ewpatton committed Feb 22, 2019
1 parent 642052c commit 4cfd02b1a6f0e739d96320824486f194c9e8108d
Showing with 14 additions and 15 deletions.
  1. +14 −4 appinventor/blocklyeditor/src/backpack.js
  2. +0 −11 appinventor/blocklyeditor/src/workspace_svg.js
@@ -218,7 +218,7 @@ Blockly.Backpack.prototype.init = function() {
// Fixes a bug in Firefox where the backpack cannot be opened.
Blockly.bindEvent_(this.svgBody_, 'mousedown', this, function(e) { e.stopPropagation(); e.preventDefault(); });
Blockly.bindEvent_(this.svgBody_, 'click', this, this.openBackpack);
Blockly.bindEvent_(this.svgBody_, 'contextmenu', this, this.openBackpackDoc);
Blockly.bindEvent_(this.svgBody_, 'contextmenu', this, this.openBackpackMenu);
this.flyout_.init(this.workspace_);
this.flyout_.workspace_.isBackpack = true;

@@ -425,9 +425,9 @@ Blockly.Backpack.prototype.position_ = function() {
};

/**
* On right click, open alert and show documentation
* On right click, open alert and show documentation and backpackClear
*/
Blockly.Backpack.prototype.openBackpackDoc = function(e) {
Blockly.Backpack.prototype.openBackpackMenu = function(e) {
var options = [];
var backpackDoc = {enabled : true};
backpackDoc.text = Blockly.Msg.SHOW_BACKPACK_DOCUMENTATION;
@@ -440,6 +440,17 @@ Blockly.Backpack.prototype.openBackpackDoc = function(e) {
});
};
options.push(backpackDoc);

// Clear backpack.
var backpackClear = {enabled: true};
backpackClear.text = Blockly.Msg.BACKPACK_EMPTY;
backpackClear.callback = function() {
if (Blockly.getMainWorkspace().hasBackpack()) {
Blockly.getMainWorkspace().getBackpack().clear();
}
};
options.push(backpackClear);

Blockly.ContextMenu.show(e, options, this.workspace_.RTL);
// Do not propagate to Blockly, nor show the browser context menu
//e.stopPropagation();
@@ -667,4 +678,3 @@ Blockly.Backpack.prototype.resize = function() {
this.shrink();
}
};

@@ -791,17 +791,6 @@ Blockly.WorkspaceSvg.prototype.customContextMenu = function(menuOptions) {
};
menuOptions.push(backpackCopyAll);

// Clear backpack.
var backpackClear = {enabled: true};
backpackClear.text = Blockly.Msg.BACKPACK_EMPTY;
backpackClear.callback = function() {
if (Blockly.getMainWorkspace().hasBackpack()) {
Blockly.getMainWorkspace().getBackpack().clear();
}
backpackRetrieve.text = Blockly.Msg.BACKPACK_GET;
};
menuOptions.push(backpackClear);

// Enable grid
var gridOption = {enabled: true};
gridOption.text = this.options.gridOptions['enabled'] ? Blockly.Msg.DISABLE_GRID :

0 comments on commit 4cfd02b

Please sign in to comment.
You can’t perform that action at this time.