Help with iteration
-
What's a dot box?
The parameter you pass to
getComponent
needs to be the id of the component - I don't think your component is called "DotBox[i]".I'm assuming your components are going to be called something like "DotBox0", "DotBox1", etc.
So you need to append
i
to the end of the name, like soContent.getComponent("DotBox" + i);
You could also use
Content.getAllComponents("DotBox\\d")
which will create an array containing references to all components with "DotBox" in the name followed by a number.Also you can't declare a const in a loop, and you wouldn't want to here. Instead declare your array outside of the loop.
-
As the console warning message says, const var declarations must be on global level. So it can't be in a function or loop.
Also
push
is a good way to create such arrays.const var arry_DotBox = []; for (i = 0; i < 16; i++) { arry_DotBox.push(Content.getComponent("DotBox" + i)); arry_DotBox[i].setLocalLookAndFeel(dotBoxLaf); }
-
@d-healey said in Help with iteration:
What's a dot box?
A "DotBox" is just a modification of your checkbox.
I prefer the dots for button matrices: -
@VirtualVirgin for that use case it's better to use a panel rather than an array of buttons. Using a panel is also dynamic so you can change the number of dot boxes on the fly
-
@VirtualVirgin You might want to check this out
https://forum.hise.audio/topic/7049/my-tooth-hurts?_=1731938031853
But I don't guarantee the snippet will load because it's quite old...
-
This post is deleted! -
This post is deleted! -
@d-healey said in Help with iteration:
@VirtualVirgin for that use case it's better to use a panel rather than an array of buttons. Using a panel is also dynamic so you can change the number of dot boxes on the fly
In the example above the buttons are already on a panel.
Are you saying I should use a panel instead of buttons?
I can get multiple values from different places on a panel? -
@VirtualVirgin said in Help with iteration:
Are you saying I should use a panel instead of buttons?
Yes. Take a look at this (1:45:44)
-
This post is deleted! -
@VirtualVirgin Sorry about the multiples! I kept getting a "bad gateway error" when trying to post and it didn't look like they went through.
-
@VirtualVirgin just delete them then.