Unique ID and value with duplication

Hi,
I'm working on my first patch which is a controller for Hy-Rep2, which contain 8 same track sequencing.
After creating my first track I wanted to duplicate it to create "Track02" but they are sharing same value despite I change the main panel container.
Does it means I need to customize every controller ?
Best

Clone is a great tool !

Yes. A way to do so is to use the panel's variables property:

{
  "n": 1
}

And use it to define it's children's ids (@{parent.variables.n}). When copying the panel, incrementing that variable will increment all the children too. If using a clone widget, the variables property can be overridden with the props property:

{
  "variables": {"n": 2}
}

Edit: it's also possible to use the paste action "ID + 1" that will simply paste copied widgets and increment their id automatically.

1 Like

The paste function “ID + 1” is fine, I didn’t saw it because I’m always using shortcut.
But I need to understand "n" : 1 solution.
btw it can be a cool solution to have hierarchy :slight_smile:

A problem with "ID +1" is that doesn’t take the update +1 on “text” that is getting value from @{knob}
And at this time I did not succeed with the
( @{parent.variables.n} )

A problem with "ID +1" is that doesn’t take the update +1 on “text” that is getting value from @{knob}

That's a limitation indeed. To do that with the variables method you have to to write something like
@{knob_@{parent.variables.n}}

1 Like

Ok I’ll re try again later !
So this has to be implement at the begin of the patch creation.

sorry I don't get it, I tried to follow your explication but I'm totally lost by where to use where as well for copy +1 or clone.

> "responsive is really powerful"

copy_clone_test.json (6.5 KB)

Here is a simple example: clone_variable_n.json (5.5 KB)
The panel on the left is the “template” widget, its variables property is used to define its children’s ids (and the texts’ values). The panel on the right is a clone widget targeting the template widget that overrides the variables property.

so I’m diving into cloning, it seems to be really powerful,
I’m only have one problem
in my midi prearg I wrote :
[
6,
20 + @{parent.variables.n}
]
and … that’s not working like this :confused:

20 + @{parent.variables.n}

You need to put that in a #{} or JS{{}} block, click on the properties name in the inspector, you'll see what your current code outputs.

1 Like

great :slight_smile:

I have this matrix button with custom js in the props so I tried to add the #{} but did not work I changed the JS{{}} by #{} which can contain other #{} but same error :

JS{{
var props = {}
var labels = ["mute", "solo"]
props.mode = "toggle"
props.label = labels[$]
props.target = "@{variable_midi}"
props.on = 127
props.off = 0
props.address =  "/control"
props.preArgs = [3, $+#{43+@{parent.variables.n}}]
return props
}}

You’re already in a JS{{}}, you don’t need that #{} block.

made some different test

this should looks like this isn’t it ?
I have almost finish different patch and will share it soon

JS{{
var props = {}
var labels = ["mute", "solo"]
props.mode = "toggle"
props.label = labels[$]
props.target = "@{variable_midi}"
props.on = 127
props.off = 0
props.address =  "/control"
props.preArgs = [3, $+43+@{this.variables.n}]
return props
}}

You shouldn't put quotes here.

1 Like