How to create a pad-like component for a apvts Choice Parameter?

Hello all,
In my plugin I have a choice parameter which allows the user to choose the base wave shape (sin, sawtooth etc). Now that I’ve moved onto creating the actual editor, I would like to create a custom component that is not a dropdown to allow the user to interact with the parameter.

What I want is a 2x2 grid of buttons, styled to look like pads from a drum machine/launchpad type thing. I’ve got a very rough prototype working where the buttons are provided a callback that looks something like

button.onClick = [&choiceParameter, buttonIndex](){ choiceParameter = trySetChoiceIndex(buttonIndex) };

I also have an object that is a listener to the parameter as a member of the component, who’s callback looks like

for(size_t i = 0; i < numButtons; i++){
auto& button =;
  if(approximatelyEqual(newValue, i)){
    button.setColour(button.buttonColourId, Colours::green);
  } else {
    button.setColour(button.buttonColourId, Colours::transparentBlack);

This all functions fine. But I’m wondering if there’s any ways to improve the idea. It would be great if we could use the Button Parameter attachments and specify the value submitted when the button is pressed, but as far as I’m aware theres no way to do that. Has anyone done this before? Or have any ideas on a more elegant way to do what I want?

So turns out what I wanted was indeed a custom parameter attachment. After looking through the JUCE source code and reading this documentation entry I managed to combine the ComboBox and Button attachments to do exactly what I needed.

sounds like a radio button to me. i think juce has a class like this, too