validate: function(newValue) {
this.getSourceBlock().updateConnections(newValue);
return newValue;
},
init: function() {
var options = [
["1","Option1"],
["2","Option2"],
["3","Option3"],
];
this.appendDummyInput()
.appendField(new Blockly.FieldDropdown(options, this.validate), 'MODE');
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(210);
},
updateConnections: function(newValue) {
this.removeInput("Input1", /* no error */ true);
this.removeInput(" Input2 ", /* no error */ true);
this.removeInput(" Input3 ", /* no error */ true);
this.removeInput(" Input4 ", /* no error */ true);
this.removeInput(' Input5 ', /* no error */ true);
if (newValue == 'Option1') {
this.appendValueInput(" Input1 ")
.setCheck("String")
.appendField(" Input1 ")
this.appendValueInput(" Input2 ")
.setCheck("Number")
.appendField(" Input2 ");
} else if (newValue == 'Option2') {
this.appendValueInput(" Input13 ")
.setCheck("Number")
.appendField("Input3");
} else if (newValue == 'Option3') {
this.appendValueInput(" Input4 ")
.setCheck("Number")
.appendField(" Input4 ")
this.appendValueInput(" Input5 ")
.setCheck("Number")
.appendField(" Input5 ");
}