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

set Check method is not working in statement inputs when i am passing any custom_block as type in setcheck("position") #42

Open
manish-kumar-01 opened this issue Mar 31, 2021 · 4 comments

Comments

@manish-kumar-01
Copy link

No description provided.

@sfuller
Copy link
Contributor

sfuller commented Apr 1, 2021

Could you add an example of your code that is having the problem?

@manish-kumar-01
Copy link
Author

manish-kumar-01 commented Apr 2, 2021

Blockly.Block["trajectory"] = {
init: function () {
    this.appendDummyInput().appendField("Trajectory");
    this.appendDummyInput()
      .appendField("Name")
      .appendField(new Blockly.FieldTextInput("Traj_"), "NAME");
    this.appendStatementInput("stm_holder").setCheck('position')
    .appendField();
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setColour(165);
    this.setTooltip("");
    this.setHelpUrl("");
  },
  }

Blockly.Blocks["position"] = {
  init: function () {
    this.appendDummyInput()
        .appendField("Position (TCP Jog)");
    this.appendDummyInput()
        .appendField("Name")
        .appendField(new Blockly.FieldTextInput("Pos_"), "NAME");
    this.setPreviousStatement(true, null);
    this.setNextStatement(true, null);
    this.setTooltip("");
    this.setHelpUrl("");
  }
}

In this above block(Trajectory), I want to connect only the "position" block in its statementInput for that I have added setCheck method also. But despite that, every block is getting connected (those who has previousStatement = true).

I can not put check in position's block previous Statement, because position block can be connected with other Blocks

@sfuller
Copy link
Contributor

sfuller commented Apr 3, 2021

Just a guess, but I believe your "position" block's init function is missing a this.setOutput call. Adding this.setOutput('position') will set the return type of your position block to a position.

More Info: https://developers.google.com/blockly/guides/create-custom-blocks/type-checks

Also, this doesn't seem to be related to this repo's react bindings for Blockly. In the future, You might have an easier time finding an answer by asking a question on StackOverflow, given you include the example code and explanation like you have done here.

@madalinaaftanase
Copy link

madalinaaftanase commented May 7, 2023

Just a guess, but I believe your "position" block's init function is missing a this.setOutput call. Adding this.setOutput('position') will set the return type of your position block to a position.

"A block with a previous connector cannot have an output connector, and vice versa. The term statement block refers to a block with no value output. A statement block will usually have both a previous connection and a next connection."

I have the same problem as @manish-kumar-01 . Did you find any solution?

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

3 participants