-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Labels
Description
I want to build a block that searches in a list the input text value ad display the results in the dropdown dynamically (using blockly).
This is what I am building but I am not able to get and use the text input value:
{
"type": "search",
"message0": "%1 %2",
"args0": [
{
"type": "field_input",
"name": "input1",
"text": "whatever",
},
{
"type": "input_dummy",
"name": "INPUT"
}
],
"extensions": ["dynamic_menu_extension"],
},
Blockly.Extensions.register('dynamic_menu_extension',
function() {
this.getInput('INPUT')
.appendField(new Blockly.FieldDropdown(
function() {
var options = [];
Blockly.JavaScript['search'] = function(block) {
var searchVal = block.getFieldValue('input1');
return searchVal;}
for (var i=0 ; i < list.length ; i++)
{
if (list[i] == searchVal) {
options.push([list[i],list[i]]);
}
}
return options;
}), 'whatever1');
});
It works as if the input text field was not defined.
Reactions are currently unavailable