How would you code this custom component?

Hi, I’m new to JUCE development and I have a question about how best to approach creating a custom component… let’s call it ComboButton.

Internally, it should be similar to juce::ComboBox in that it controls a parameter value that must be one of a number of options. Ideally it would be attached to a juce::AudioProcessorValueTreeState.

The way in which ComboButton would be different from ComboBox is that the component’s GUI should present something like a singular TextButton. Each time the button is clicked, the value would toggle or rotate through a number of possible parameter values. The active value could present in the button GUI itself, or be reflected elsewhere in the plugin interface.

I’m wondering how an experienced JUCE developer would approach building this type of component. Any advice you can provide would be greatly appreciated.

Sounds like it’s a regular push button that simply increments an index parameter when clicked.

So I’d use a normal juce::TextButton but write a custom ParameterAttachment class to implement the custom logic. You’ll want to use an AudioParameterChoice and keep track of the active index in the attachment class and update the button’s text when the parameter value changes.

Maybe compare the ComboBox and Button attachments to build the hybrid approach you need:

2 Likes