{
init: function() {
// ....
var thisBlock = this;
var dropdown = new Blockly.FieldDropdown([...], function(newOp) {
thisBlock.updateType_(newOp);
});
// ....
},
updateType_: function(newOp) {
if (newOp == 'STRING') {
this.setColour(200);
this.outputConnection.setCheck('String');
} else if(newOp == 'NUMBER') {
this.setColour(100);
this.outputConnection.setCheck('Number');
}
},
// storing output type
mutationToDom: function() {
var container = document.createElement('mutation');
container.setAttribute('op', this.getFieldValue('OP'));
return container;
},
// retrieving output type
domToMutation: function(xmlElement) {
this.updateType_(xmlElement.getAttribute('op'));
}
};