Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The xml of dynamic appendField block is not included #4752

Closed
fewiki opened this issue Apr 1, 2021 · 1 comment
Closed

The xml of dynamic appendField block is not included #4752

fewiki opened this issue Apr 1, 2021 · 1 comment

Comments

@fewiki
Copy link

fewiki commented Apr 1, 2021

Hi,excuse me, I have a problem,I can not get xml of dynamic appendField block.

my block:

// block json
 {
  'message0': ' %1',
  'name': 'valInput',
  'colour': '#7167C1',
  'output': null,
  'args0': [
   {
    'type': 'input_dummy',
    'name': 'valInputTypeList',
   },
  ],
  'inputsInline': true,
  'extensions': ['valInputTypeList'],
}

// extension
Blockly.Extensions.register('valInputTypeList', function() {
  this.getInput('valInputTypeList').appendField(new Blockly.FieldDropdown(() => {
  let options = [['custom input', '1']]
  return options
  }), 'valInputTypeList')
})

// dynamic field append
this.getField('valInputTypeList').setValidator((value) => {
  this.removeInput('emptyInput', true)
  this.appendDummyInput('emptyInput').appendField(new Blockly.FieldTextInput('',           function(data) {
        console.log('data:', data)
   }, 'valInput'))
  }
})

When I get the xml,the 'valInput' field in not in the xml

let xmlDom = Blockly.Xml.workspaceToDom(Blockly.getMainWorkspace())
let xmlText = Blockly.Xml.domToText(xmlDom)

QQ截图20210401101117

How can get the xml of dynamic append field, thanks .

@fewiki fewiki added issue: triage Issues awaiting triage by a Blockly team member issue: bug Describes why the code or behaviour is wrong labels Apr 1, 2021
@fewiki
Copy link
Author

fewiki commented Apr 1, 2021

It's my falt. The bracket is at the end.

this.getInput('valInputTypeList').appendField(new Blockly.FieldDropdown(() => {
let options = [['custom input', '1']]
return options
}, 'valInputTypeList'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants