Skip to content

Commit

Permalink
Remove 'duplicate' from script browser block menus (fixes #57); remov…
Browse files Browse the repository at this point in the history
…e 'add comment' from any block menu
  • Loading branch information
towerofnix committed Aug 18, 2017
1 parent 4c0e842 commit d259653
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/blocks/Block.as
Original file line number Diff line number Diff line change
Expand Up @@ -848,16 +848,16 @@ package blocks {

/* Menu */

public function menu(evt:MouseEvent):void {
public function menu(evt:MouseEvent, fromScriptBrowser:Boolean = false):void {
// Note: Unlike most menu() methods, this method invokes
// the menu itself rather than returning a menu to the caller.
if (scriptBrowserBlock) {
originalBlock.menu(evt);
originalBlock.menu(evt, true);
return;
}
if (MenuHandlerFunction == null) return;
if (isEmbeddedInProcHat()) MenuHandlerFunction(null, parent);
else MenuHandlerFunction(null, this);
if (isEmbeddedInProcHat()) MenuHandlerFunction(null, parent, null, null, fromScriptBrowser);
else MenuHandlerFunction(null, this, null, null, fromScriptBrowser);
}

public function handleTool(tool:String, evt:MouseEvent):void {
Expand Down
12 changes: 6 additions & 6 deletions src/scratch/BlockMenus.as
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@ package scratch {
private var startY:Number;
private var block:Block;
private var blockArg:BlockArg; // null if menu is invoked on a block
private var fromScriptBrowser:Boolean; // true if menu is invoked on a script browser block

private static const basicMathOps:Array = ['+', '-', '*', '/'];
private static const comparisonOps:Array = ['<', '=', '>'];

private static const spriteAttributes:Array = ['x position', 'y position', 'direction', 'costume #', 'costume name', 'size', 'volume'];
private static const stageAttributes:Array = ['backdrop #', 'backdrop name', 'volume'];

public static function BlockMenuHandler(evt:MouseEvent, block:Block, blockArg:BlockArg = null, menuName:String = null):void {
var menuHandler:BlockMenus = new BlockMenus(block, blockArg);
public static function BlockMenuHandler(evt:MouseEvent, block:Block, blockArg:BlockArg = null, menuName:String = null, fromScriptBrowser:Boolean = false):void {
var menuHandler:BlockMenus = new BlockMenus(block, blockArg, fromScriptBrowser);
var op:String = block.op;
if (menuName == null) { // menu gesture on a block (vs. an arg)
if (op == Specs.GET_LIST) menuName = 'list';
Expand Down Expand Up @@ -156,12 +157,13 @@ package scratch {
];
}

public function BlockMenus(block:Block, blockArg:BlockArg) {
public function BlockMenus(block:Block, blockArg:BlockArg, fromScriptBrowser:Boolean = false) {
app = Scratch.app;
this.startX = app.mouseX;
this.startY = app.mouseY;
this.blockArg = blockArg;
this.block = block;
this.fromScriptBrowser = fromScriptBrowser;
}

public static function shouldTranslateItemForMenu(item:String, menuName:String):Boolean {
Expand Down Expand Up @@ -525,14 +527,12 @@ package scratch {
if (!block) return;
m.addLine();
if (!isInPalette(block)) {
if (!block.isProcDef()) {
if (!block.isProcDef() && !fromScriptBrowser) {
m.addItem('duplicate', duplicateStack);
}
m.addItem('delete', block.deleteStack);
m.addLine();
m.addItem('add comment', block.addComment);
}
//m.addItem('help', block.showHelp);
m.addItem('show spec', block.showSpec);
m.addLine();
}
Expand Down

0 comments on commit d259653

Please sign in to comment.