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

How to generate empty input value with shadow? #915

Closed
greenSnot opened this issue Jun 2, 2017 · 7 comments
Closed

How to generate empty input value with shadow? #915

greenSnot opened this issue Jun 2, 2017 · 7 comments

Comments

@greenSnot
Copy link
Contributor

image

I am going to implement this feature #904, The problem is

this.appendValueInput(param_name);

shows nothing but I expect to be rounded shadow (empty input)
image

    var opt:BlockRegisOpt = {
      is_procedure_call: true,
      id: '__PROCEDURE_CALL__' + name,
      type: p.output_type ? 'procedure_call_return' : 'procedure_call_no_return',
      message0: '%1',
      args0: [{
        type: 'field_label',
        name: 'NAME',
      }],
      previous_statement: p.output_type ? false : true ,
      next_statement: p.output_type ? false : true,
      //TODO
      output: p.output_type ? 'String' : undefined,
      category: 'procedure',
      xml: `
        <field name="NAME"></field>
      `,
      mutation_to_dom: function() {
        var container = document.createElement('mutation');
        this.setFieldValue(name, 'NAME');
        for (let param_name in procedure_map[name].params) {
          var parameter = document.createElement('param');
          parameter.setAttribute('name', param_name);
          container.appendChild(parameter);
          if (!this.getInput(param_name)) {
            let input = this.appendValueInput(param_name);
            //let field = new Blockly.FieldTextInput(i);
            //input.appendField(field);
          }
        }
        return container;
      },
      dom_to_mutation: function(element) {
        let param_list = element.getElementsByTagName('param');
        this.params = [];
        for (var i = 0; i < param_list.length; i++) {
          this.params.push(param_list[i].getAttribute('name'));
        }
        //TODO
      },
    };

@thisandagain
Copy link
Contributor

Tracking feature request in scratchfoundation/scratch-vm#79

@thisandagain thisandagain added this to the Backlog milestone Jun 5, 2017
@greenSnot
Copy link
Contributor Author

@thisandagain they are different issues. This seems like a bug? I am not sure, I just want to make a empty input.

@rachel-fenichel
Copy link
Collaborator

rachel-fenichel commented Jun 5, 2017

@greenSnot in your XML, add a shadow block to it and see if it renders correctly.

@greenSnot
Copy link
Contributor Author

@rachel-fenichel , I want to append an empty input after Block.jsonInit. Is that possible?

@greenSnot
Copy link
Contributor Author

@rachel-fenichel Oh, and If I define procedure block "MethodA with parameter x" and "MethodB with parameter x,y,z" they are both "procedure_call" type but different number of input value. So I can't do it in its xml & args0 before jsonInit.

@rachel-fenichel
Copy link
Collaborator

I see. Then this is a design question, about what block shapes are valid, so I'll defer to the scratch team.

@greenSnot
Copy link
Contributor Author

Solved:)
@rachel-fenichel you might need this in core/block.js

  Blockly.Block.prototype.appendShadow_ = function(type, name) {
    var connection = this.makeConnection_(type);
    var input = new Blockly.Input(type, name, this, connection);
    this.inputList.push(input);
    var blocks = this.getDescendants();
    for (let i = 0; i < blocks.length; i++) {
      blocks[i].initSvg();
      blocks[i].render(false);
    }
    this.updateDisabled();
    Blockly.resizeSvgContents(this.workspace);
    return input;
  };

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

No branches or pull requests

3 participants