rete icon indicating copy to clipboard operation
rete copied to clipboard

Input sockets for controls?

Open exellian opened this issue 2 years ago • 1 comments

Is it somehow possible to create an input socket for a control. I didn't find anything on docs. Or is there some way to workaround this?

exellian avatar Dec 17 '21 15:12 exellian

You can use the input of the node and pass the value to the control like this:

worker(node, inputs, outputs) {
    const n1 = inputs.num1.length ? inputs.num1[0] : node.data.num1;
    const n2 = inputs.num2.length ? inputs.num2[0] : node.data.num2;
    const sum = n1 + n2;

    this.editor.nodes
      .find((n) => n.id === node.id)
      .controls.get("preview")
      .setValue(sum);
    outputs.num = sum;
  }

where setValue is this function on the Control:

 setValue(val) {
    this.props.value = val.toFixed(3);
    this.putData(this.key, val);
    this.update();
  }

If you need a full example I can share it with you

jayemes avatar Jan 04 '22 20:01 jayemes

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

rete-js[bot] avatar Jul 13 '23 10:07 rete-js[bot]