fix disabling control_if block

This commit is contained in:
Silver Kuusik 2018-01-15 15:09:54 +01:00
parent 79e9683918
commit bc5169fbf0
2 changed files with 4 additions and 6 deletions

View File

@ -75,7 +75,7 @@
</xml> </xml>
<xml id="toolbox_no_if" style="display: none"> <xml id="toolbox_no_if" style="display: none">
<block type="controls_if"></block> <block type="controls_if" disabled="true"></block>
<block type="sumorobot_move"></block> <block type="sumorobot_move"></block>
<block type="sumorobot_delay"></block> <block type="sumorobot_delay"></block>
<block type="sumorobot_enemy"></block> <block type="sumorobot_enemy"></block>

View File

@ -295,6 +295,8 @@ window.onload = function() {
} else if (event.type == Blockly.Events.DELETE && event.oldXml.getAttributeNode("type").nodeValue == "controls_if") { } else if (event.type == Blockly.Events.DELETE && event.oldXml.getAttributeNode("type").nodeValue == "controls_if") {
/* remove the control_if block id */ /* remove the control_if block id */
controlBlockId = ""; controlBlockId = "";
/* enable the if condition block */
workspace.updateToolbox(document.getElementById("toolbox"));
} }
/* only process change and move commands */ /* only process change and move commands */
@ -309,14 +311,10 @@ window.onload = function() {
var xml = Blockly.Xml.workspaceToDom(workspace); var xml = Blockly.Xml.workspaceToDom(workspace);
localStorage.setItem("sumorobot.currentProgram", Blockly.Xml.domToText(xml)); localStorage.setItem("sumorobot.currentProgram", Blockly.Xml.domToText(xml));
/* if control_if is used*/ /* if control_if block is used */
if (controlBlockId != "") { if (controlBlockId != "") {
/* disable the if condition block */ /* disable the if condition block */
workspace.updateToolbox(document.getElementById("toolbox_no_if")); workspace.updateToolbox(document.getElementById("toolbox_no_if"));
/* if no control_if is used */
} else {
/* enable the if condition block */
workspace.updateToolbox(document.getElementById("toolbox"));
} }
} }