Closed WilliamHarmonMS closed 6 years ago
Hmm. Any thoughts on this one @paulkaplan?
Could you provide steps that I could use to reproduce something like this locally? Here is what I tried:
Blockly.Blocks['motion_dummy'] = {
init: function() {
this.jsonInit({
"message0": "glide %1 secs to %2",
"args0": [
{
"type": "input_value",
"name": "SECS"
},
{
"type": "input_value",
"name": "TO"
}
],
"category": Blockly.Categories.motion,
"extensions": ["colours_motion", "shape_statement"]
});
}
};
Blockly.Blocks['motion_menu'] = { init: function() { this.jsonInit({ "message0": "%1", "args0": [ { "type": "field_dropdown", "name": "TO", "options": [ ['1', '1'], ['2', '2'] ] } ], "colour": Blockly.Colours.motion.secondary, "colourSecondary": Blockly.Colours.motion.secondary, "colourTertiary": Blockly.Colours.motion.tertiary, "extensions": ["output_string"] }); } };
2. Added the blocks to the default toolbox
'<block type="motion_dummy">'+
'<value name="SECS">'+
'<shadow type="math_number">'+
'<field name="NUM">1</field>'+
'</shadow>'+
'</value>'+
'<value name="TO">'+
'<shadow type="motion_menu">'+
'</shadow>'+
'</value>'+
'</block>'+
3. Menu works correctly in the toolbox like you said
4. I'm not exactly sure what you mean by "instantiate". I tried dragging the block out of the toolbox, saving the XML and opening reloading it (using the "vertical playground" in scratch-blocks). Seemed to work correctly. How can I reproduce what you were seeing?
Closing due to lack of activity
Expected Behavior
When creating new custom blocks, drop down menus should have default arguments
Actual Behavior
Upon instantiation, the default arguments for drop down menus revert to 'undefined'
Steps to Reproduce
Here are some images to show what I mean: We see that in the toolbox, there are default arguments for both fields in the block:
However, upon instantiation, the default value for the dropdown menu is lost (UNLIKE the motion block which is shown for comparison).
To compare those two blocks right there, as they’re defined in make-toolbox-xml.js within the scratch-gui repo, we see: value name="INDEX" shadow type="minecraft_agentindex_menu" /shadow /value Vs value name="TO" shadow type="motion_glideto_menu" /shadow /value
Likewise their definitions in \scratch-blocks\blocks_vertical\file_name.js and \scratch-vm\src\blocks\scratch3_file_name.js are identically formatted.
Does anyone have any idea why default arguments, when instantiated are lost in new blocks?
Operating System and Browser
Win10 | version 1709 | OS Build 16299.19
Browser: N/A, I am hosting the environment within the webview of an Electron application.