Text matrix linked to fader matrix only updating when first fader is moved?

I’m trying to get a display of the value for each fader in a matrix. I got the values to show, but they are only being updated by the first fader, even though console.log-ing shows that the text value is in fact changing with every fader…

Here is my props for my faders: (I’m starting at Index 0, hence the “$+1”)
{
“typeTags”: “f”,
“id”: “/composition/layers/#{$+1}/video/opacity”
“address”: “/composition/layers/#{$+1}/video/opacity”,
“target”: “@{osc_r}”
}

and the code for my text matrix:
JS{{
var props = {}
props.id = “opacityFaderLabels #{$}”
props.value = "Layer #{$+1} " + "// " + @{opacityFaders.value}[$]
return props
}}

I also tried adding the function updateProp(“opacityFaderLabels”, value) to my fader scripts, but that didn’t help either…
Is this a bug I should report, or am I doing something wrong? Hahah
Thank you :slight_smile:

You can't use the #{} syntax in a JS{{}} block and you don't need to:

JS{{
var props = {}
props.id = "opacityFaderLabels" + $
props.value = "Layer " + ($ +1) + "// " + @{opacityFaders.value}[$]
return props
}}

Even then I strongly discourage the use of @{opacityFaders.value} here because the whole matrix is going to be rebuilt whenever the value updates. You could instead simply give each fader and text widget a linkId (based on the $ index) that will link them two by two.

1 Like

Ohhhh, I see! Thank you so much! I’ll try it in just a minute and report back! :slight_smile:

@jean-emmanuel is there a way to limit the decimals that show in the text box?
When I link float type widgets to text boxes, the values show too many decimals and are not really useable :confused:

Screenshot 2020-12-05 005650

And is there a way to add a string to them when I link them with a linkId? Like "Layer $ " + value for instance?

That may be a bug (handling when decimals are cut is tricky), you can circumvent it by using an input widget instead of a text widget or by following my second answer.

And is there a way to add a string to them when I link them with a linkId? Like "Layer $ " + value for instance?

To do that, you'd have to get rid of the linkId and ìnstead write the text's value property so that it depends on the fader's value. Usually it would look like @{fader_id} but since you're using matrices it's a bit more complicated and I suggest you check out the clones_and_variables.json example from this thread.

The idea is to build a template widget that contains both the slider and the text widgets, define their id so that it depends on the container's variables, and override the variables when cloning or duplicating the container (with a clone matrix).

1 Like

to limit decimal you can use

.toFixed(2)

1 Like

Well that’s not possible when using linkId but otherwise it’s fine when using advanced syntaxes of scripting.

1 Like