Issues with Button::onClick and radio buttons

I was confused with the behavior of the application until I realized that the current button in the “on” state also sends a click when it goes to the “off” state. Maybe this should be documented since it only refers to the clicked button. Although I think the ideal would be that in addition to onClick and onStateChange, there should be something like onDown or onToggleOn

So I finally solved it by checking the toggle state, however I have not been able to refer to the button itself since it is in an array, although it would be more useful to pass the index.

for (int i=0;i<4;i++) {
button[i].onClick = [ this ] () { bool bState = button[i].getToggleState(); // ERROR !!! };
}

so i have finally unrolled the loop, but this is not acceptable. What if there were 30 buttons?. what solution is there for this?

you can capture i


for (int i=0;i<4;i++) {
button[i].onClick = [ this, i ] () { bool bState = button[i].getToggleState(); // ERROR !!! };
}
1 Like

this is exactly what i was looking for, Thank you