Hide the parameters because there are too many and they don't look neat enough

100 views
Skip to first unread message

yilin

unread,
Jun 4, 2021, 4:05:39 AM6/4/21
to Blockly
Hello, recently looking for hidden parameter method, hope to give some help, thank you!

A block with more than 10 parameters looks very bloated. I wish I could hide it and use dialog to add values, but I can't find a way to do that.custom mutator is not enough. What should I do?

Beka Westberg

unread,
Jun 4, 2021, 4:09:18 PM6/4/21
to blo...@googlegroups.com
Hello,

Could you explain a little bit more about what you're looking for, and how the mutator doesn't work for you? "Mutators" at the core are just a way to add custom serialization to a block, so if the UI is your issue you can switch that out for something else. For example, there is a plus/minus plugin that changes the default mutators to plus/minus mutators.

And I know there are other people that have had the same issue, so hopefully some of them can chime in with their solutions as well =)

But I hope this gives you some place to start! Best wishes,
--Beka

On Fri, Jun 4, 2021 at 1:05 AM yilin <wsluo...@gmail.com> wrote:
Hello, recently looking for hidden parameter method, hope to give some help, thank you!

A block with more than 10 parameters looks very bloated. I wish I could hide it and use dialog to add values, but I can't find a way to do that.custom mutator is not enough. What should I do?

--
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/8285137d-8ac2-4910-96dd-cb76d710412an%40googlegroups.com.

yilin

unread,
Jun 7, 2021, 12:19:33 AM6/7/21
to Blockly
Thank you, I need to hide the parameters to make it a little bit cleaner.It's unimaginable if it's not hidden.Here's what one of my blocks contains:

{
    "type": "straight_path",
    "message0": "%1 path %2 fileName %3 %4 %5 X %6 %7 Y %8 %9 Z %10 %11 Roll %12 %13 Pitch %14 %15 Yaw %16 %17 %18 endX %19 %20 endY %21 %22 endZ %23 %24 endRoll %25 %26 endPitch %27 %28 endYaw %29",
    "args0": [
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_input",
        "name": "fileName",
        "text": "name"
      },
      {
        "type": "input_dummy"
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "X",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "Y",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "Z",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "Roll",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "Pitch",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "Yaw",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "input_dummy"
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "endX",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "endY",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "endZ",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "endRoll",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "endPitch",
        "value": 0,
        "min": 0,
        "max": 999
      },
      {
        "type": "field_label_serializable",
        "name": "",
        "text": ""
      },
      {
        "type": "field_number",
        "name": "endYaw",
        "value": 0,
        "min": 0,
        "max": 999
      }
    ],
    "previousStatement": null,
    "nextStatement": null,
    "colour": 160,
    "tooltip": "",
    "helpUrl": ""
  }

Coda Highland

unread,
Jun 7, 2021, 12:51:02 AM6/7/21
to blo...@googlegroups.com
Maybe it just shouldn't be one block. Maybe it can be nested blocks, with a main "path" block that contains a list of optional blocks for the various groups of parameters.

Or maybe you need a custom renderer -- perhaps something read-only with a button that you click to pop open a dialog for editing the parameters.

I've done both. Colors and dates for example work well with an edit popup, and the Blocky playground uses nested blocks to construct block descriptions, as does the way my project defines (typed) function prototypes.

/s/ Adam


Koen Van Wijk

unread,
Jun 7, 2021, 3:25:37 AM6/7/21
to Blockly
@Adam could you share a link to your typed function prototypes implementation?

Coda Highland

unread,
Jun 8, 2021, 7:40:25 PM6/8/21
to blo...@googlegroups.com
Demo: http://greenmaw.com//html52d-blockly/
Code: https://bitbucket.org/ahigerd/html52d/

In the "Edit" dropdown, click "random_distance". Though it seems I remembered wrong; I don't have types here, just variable names and input labels. Adding types wouldn't be particularly difficult, though, and other parts of this system are at least somewhat strongly typed in order to make sure that member variables and methods work right. (This is incomplete and kind of buggy; the function stuff is what I was working on when I last touched this project, and it's been a while since I've been able to come back to it.)

Note that Blockly's standard function blocks use the mutator UI to do the same thing; that's another inspiration you might look at. It's similar to one of the other ideas I mentioned -- use a popup to configure what parts you want to show.

/s/ Adam


/s/ Adam

Reply all
Reply to author
Forward
0 new messages