var gotoBlock = Blockly.Block.obtain(primaryWorkspace, 'block_goto');
var options = [["option1", "option1"], ["option2", "option2"]];
var drop = gotoBlock.getField("LABEL");
drop.menuGenerator_ = options;
Blockly.Extensions.registerExtension('my_dynamic_dropdown_extension',
new function() {
var dynamicOptions = function() { ... }
var dropdown = new Blockly.FieldDropdown(dynamicOptions);
this.inputList[0].appendField(dropdown, 'MY_DYNAMIC_DROPDOWN')
});--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{
"type": "block_goto",
"message0": "Goto %1","args0" :
[
{
"type": "field_dropdown",
"name": "LABEL",
"options":
[
["Label1","Label1"],
["Label2","Label2"]
]
}
],
"previousStatement": null,
"nextStatement": null,
"colour": 60,
"tooltip": "",
"helpUrl": "",
"extensions": ["test_extension"]
} Blockly.Extensions.registerExtension('test_extension',
new function() {
var dynamicOptions = function () {
var options = [["option1", "option1"], ["option2", "option2"]];
return options;
}
var dropdown = new Blockly.FieldDropdown(dynamicOptions);
this.inputList[0].appendField(dropdown, 'LABEL')
});HI,
I am also very interested in the solution to that request.
How should we do if we would like to avoid the double creation of fieldLABEL ?
Is there a kind of `updateField` instead of `appendField`?
--
You received this message because you are subscribed to a topic in the Google Groups "Blockly" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/blockly/4yDynlV-Q1I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to blockly+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.