Re: appending a Field to an existing dummy input

199 views
Skip to first unread message

Beka Westberg

unread,
Oct 22, 2021, 12:44:49 PM10/22/21
to blo...@googlegroups.com
Hello,

You can use `block.getInput('MY_INPUT_NAME').appendField(newField)`

I hope that helps! If you have any further questions please reply!
--Beka

On Fri, Oct 22, 2021 at 6:47 AM Julian <juliand...@gmail.com> wrote:
How can in append a field without using appendDummyInput, because I want to add it to an existing dummyInput instead of making a new one. In the Blockly.blocks['blockName'] I want to use jsonInit and append a field to and existing dummyInput.

--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/5a9ab4e4-f74f-42ca-82d7-34e3ccf393c5n%40googlegroups.com.

Julian

unread,
Oct 22, 2021, 2:03:24 PM10/22/21
to Blockly
I tried a lot of different things nothing worked, because dummy input doesn't have a name to access it. Then after a lot of trial and error I tried this.getInput( ' ' ) which worked that way I could use appendField() to an existing dummy field inside the init code of a block.

So I don't really know why I have to access the block like this? ( btw it only work like this getInput( ' ' ), this doesn't work: getInput(  ) )

Julian

Op vrijdag 22 oktober 2021 om 18:44:49 UTC+2 schreef bekawe...@gmail.com:

Beka Westberg

unread,
Oct 22, 2021, 2:54:24 PM10/22/21
to blo...@googlegroups.com
Oh! You can also give your dummy input a name, which should make it easier to access later.

Like:

```
init: function() {
  this.appendDummyInput('MY_DUMMY_INPUT_NAME');
  // Other initialization etc....
}

somethingElse: function() {
   // Append a new field to the input.
  this.getInput('MY_DUMMY_INPUT_NAME')
    .appendField(new Field());
}
```

I hope that helps! Best wishes!
--Beka

Julian

unread,
Oct 25, 2021, 6:58:30 AM10/25/21
to Blockly
Oh oke thx, that makes it a lot easier and clearer!

Op vrijdag 22 oktober 2021 om 20:54:24 UTC+2 schreef bekawe...@gmail.com:
Reply all
Reply to author
Forward
0 new messages