diff --git a/sumorobot.js b/sumorobot.js index e50669f..d996308 100755 --- a/sumorobot.js +++ b/sumorobot.js @@ -282,10 +282,17 @@ window.onload = function() { /* when mouse click occures on Blockly workspace */ Blockly.utils.isRightButton = function(e) { - /* if control_if block is used */ + var target = e.target; + + /* when control_if block is in use */ if (controlBlockId != "") { - /* close the control_if block mutator */ - workspace.getBlockById(controlBlockId).mutator.setVisible(false); + /* when the user clicks anywhere outside the mutator and not on the mutator icon */ + if (!$(target).is('.blocklyBubbleCanvas') && !$(target).parents().is('.blocklyBubbleCanvas')) { + if (!$(target).is('.blocklyIconGroup') && !$(target).parents().is('.blocklyIconGroup')) { + /* hide the mutator */ + workspace.getBlockById(controlBlockId).mutator.setVisible(false); + } + } } /* disable right click on Blockly workspace */ return false; @@ -510,7 +517,7 @@ window.onload = function() { var target = e.target; /* when control_if block is in use */ - if (controlBlockId) { + if (controlBlockId != "") { /* when the user clicks anywhere outside the mutator and not on the mutator icon */ if (!$(target).is('.blocklyBubbleCanvas') && !$(target).parents().is('.blocklyBubbleCanvas')) { if (!$(target).is('.blocklyIconGroup') && !$(target).parents().is('.blocklyIconGroup')) {