Something that’s often forgotten about
Component (and that’s therefore inherited by all other widgets, like
Button), is that they come with a
NamedValueSet where you can set any sort of property for later usage.
In your case, you could store there the index of the receiver that each button should interact with, like this:
button->getProperties().set ("receiverIndex", i);
and then retrieve it later in your buttonClicked() like this:
int receiverIndex = button->getProperties() ["receiverIndex"];
This saves the need for the “indexOf” search in the array, and also drops the constraint that receivers and buttons must have the same indices in their respective arrays.