Hi Blockly team
we are trying to do some work based on blockly. it's very good tool.
we want to dynamically update the block field value, value comes from some input on the page .
I monitor the input value ,and try to update it to block field.
Try to update the value by with setFieldValue method in js.
I call this function once input field change,
Blockly.Blocks['temp'].update();
but it remind me it's not a function.
here is the block definition.
The init function is generated by blockly development tool, the update function is written by me.
Blockly.Blocks['temp'] = {
init: function() {
//var template=my_temp;
this.appendDummyInput()
.setAlign(Blockly.ALIGN_CENTRE)
.appendField("template->case");
this.appendDummyInput()
.appendField("template_name:")
.appendField(new Blockly.FieldTextInput("temp_name"), "temp");
this.appendDummyInput()
.appendField("parameters:")
.appendField(new Blockly.FieldTextInput("p1=xx;p2=xx;"), "parameters");
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(315);
debugger;
this.setTooltip("");
this.setHelpUrl("");
},
### I try to initate a update function.
update: function() {
this.setFieldValue("tesetsdf","temp");
}
};
if it not work. Do you have better method to update the block field value dynamically?
Thanks