forked from marva/sumorobot-web
		
	disable right click on Blockly workspace
This commit is contained in:
		
							
								
								
									
										16
									
								
								sumorobot.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								sumorobot.js
									
									
									
									
									
								
							@@ -172,7 +172,7 @@ window.onload = function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* change to python code */
 | 
					    /* change to python code */
 | 
				
			||||||
    Blockly.Sumorobot['controls_if'] = function(block) {
 | 
					    Blockly.Sumorobot['controls_if'] = function(block) {
 | 
				
			||||||
        // If/elseif/else condition.
 | 
					        // if/elseif/else condition.
 | 
				
			||||||
        var n = 0;
 | 
					        var n = 0;
 | 
				
			||||||
        var argument = Blockly.Sumorobot.valueToCode(block, 'IF' + n,
 | 
					        var argument = Blockly.Sumorobot.valueToCode(block, 'IF' + n,
 | 
				
			||||||
            Blockly.Sumorobot.ORDER_NONE) || 'False';
 | 
					            Blockly.Sumorobot.ORDER_NONE) || 'False';
 | 
				
			||||||
@@ -222,7 +222,7 @@ window.onload = function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    /* change the if block to be more cheerful */
 | 
					    /* change the if block to be more cheerful */
 | 
				
			||||||
    Blockly.Blocks.logic.HUE = '#44CC00';
 | 
					    Blockly.Blocks.logic.HUE = '#44CC00';
 | 
				
			||||||
    /* inject blockly */
 | 
					    /* inject Blockly */
 | 
				
			||||||
    var blocklyArea = document.getElementById('blocklyArea');
 | 
					    var blocklyArea = document.getElementById('blocklyArea');
 | 
				
			||||||
    var blocklyDiv = document.getElementById('blocklyDiv');
 | 
					    var blocklyDiv = document.getElementById('blocklyDiv');
 | 
				
			||||||
    workspace = Blockly.inject(blocklyDiv, {
 | 
					    workspace = Blockly.inject(blocklyDiv, {
 | 
				
			||||||
@@ -238,7 +238,7 @@ window.onload = function() {
 | 
				
			|||||||
        toolbox: document.getElementById('toolbox')
 | 
					        toolbox: document.getElementById('toolbox')
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* on blockly resize */
 | 
					    /* on Blockly resize */
 | 
				
			||||||
    var onresize = function(e) {
 | 
					    var onresize = function(e) {
 | 
				
			||||||
        // Compute the absolute coordinates and dimensions of blocklyArea.
 | 
					        // Compute the absolute coordinates and dimensions of blocklyArea.
 | 
				
			||||||
        var element = blocklyArea;
 | 
					        var element = blocklyArea;
 | 
				
			||||||
@@ -280,11 +280,15 @@ window.onload = function() {
 | 
				
			|||||||
    /* resume the blocks */
 | 
					    /* resume the blocks */
 | 
				
			||||||
    Blockly.Xml.domToWorkspace(xml, workspace);
 | 
					    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) {
 | 
					    function onCodeChanged(event) {
 | 
				
			||||||
        /* if the if condition block was created */
 | 
					        /* if the if condition block was created */
 | 
				
			||||||
        if (event.type == Blockly.Events.CREATE && event.xml.getAttributeNode("type").nodeValue == "controls_if") {
 | 
					        if (event.type == Blockly.Events.CREATE && event.xml.getAttributeNode("type").nodeValue == "controls_if") {
 | 
				
			||||||
 | 
					 | 
				
			||||||
            /* remember the control_if block id */
 | 
					            /* remember the control_if block id */
 | 
				
			||||||
            controlBlockId = event.blockId;
 | 
					            controlBlockId = event.blockId;
 | 
				
			||||||
            /* automatically add the else statement input */
 | 
					            /* automatically add the else statement input */
 | 
				
			||||||
@@ -430,7 +434,7 @@ window.onload = function() {
 | 
				
			|||||||
        if (pythonEnabled) {
 | 
					        if (pythonEnabled) {
 | 
				
			||||||
            /* send the code from the textarea to the SumoRobot */
 | 
					            /* send the code from the textarea to the SumoRobot */
 | 
				
			||||||
            sumorobot.send("start:" + $("#blocklyCode").val());
 | 
					            sumorobot.send("start:" + $("#blocklyCode").val());
 | 
				
			||||||
        /* otherwise when we are in blockly mode */
 | 
					        /* otherwise when we are in Blockly mode */
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            /* send the code from the blocks to the SumoRobot */
 | 
					            /* send the code from the blocks to the SumoRobot */
 | 
				
			||||||
            sumorobot.send("start:" + sumocode);
 | 
					            sumorobot.send("start:" + sumocode);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user