From 8a9423ae836a5440dcec579496624ebd49c01691 Mon Sep 17 00:00:00 2001 From: Silver Kuusik Date: Mon, 15 Jan 2018 20:18:37 +0100 Subject: [PATCH] disable right click on Blockly workspace --- sumorobot.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sumorobot.js b/sumorobot.js index bebd61a..3841ea3 100755 --- a/sumorobot.js +++ b/sumorobot.js @@ -172,7 +172,7 @@ window.onload = function() { /* change to python code */ Blockly.Sumorobot['controls_if'] = function(block) { - // If/elseif/else condition. + // if/elseif/else condition. var n = 0; var argument = Blockly.Sumorobot.valueToCode(block, 'IF' + n, Blockly.Sumorobot.ORDER_NONE) || 'False'; @@ -222,7 +222,7 @@ window.onload = function() { /* change the if block to be more cheerful */ Blockly.Blocks.logic.HUE = '#44CC00'; - /* inject blockly */ + /* inject Blockly */ var blocklyArea = document.getElementById('blocklyArea'); var blocklyDiv = document.getElementById('blocklyDiv'); workspace = Blockly.inject(blocklyDiv, { @@ -238,7 +238,7 @@ window.onload = function() { toolbox: document.getElementById('toolbox') }); - /* on blockly resize */ + /* on Blockly resize */ var onresize = function(e) { // Compute the absolute coordinates and dimensions of blocklyArea. var element = blocklyArea; @@ -280,11 +280,15 @@ window.onload = function() { /* resume the blocks */ Blockly.Xml.domToWorkspace(xml, workspace); - /* on blockly code change */ + /* disable right click on Blockly workspace */ + Blockly.utils.isRightButton = function(e) { + return false; + }; + + /* on Blockly code change */ function onCodeChanged(event) { /* if the if condition block was created */ if (event.type == Blockly.Events.CREATE && event.xml.getAttributeNode("type").nodeValue == "controls_if") { - /* remember the control_if block id */ controlBlockId = event.blockId; /* automatically add the else statement input */ @@ -430,7 +434,7 @@ window.onload = function() { if (pythonEnabled) { /* send the code from the textarea to the SumoRobot */ sumorobot.send("start:" + $("#blocklyCode").val()); - /* otherwise when we are in blockly mode */ + /* otherwise when we are in Blockly mode */ } else { /* send the code from the blocks to the SumoRobot */ sumorobot.send("start:" + sumocode);