From 3d22d8666e71d7bf6c124375698c05739e05b532 Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Mon, 15 Jan 2018 21:07:23 +0100 Subject: [PATCH] fix control_if mutator closing on touch --- sumorobot.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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')) {