ValueTree(Slider/ComboBox/RadioButtonGroup)Attachment on github


Hi all,
on the weekend I created three attachment classes to connect nodes in a ValueTree to GUI components.

They work basically the same as AudioProcessorValueTreeState::SliderAttachment, except that they don’t connect AudioProcessorParameters (visible to host), but normal ValueTrees. ValueTrees are great to serialize a state to a file or memory blocks (like AudioProcessor::getStateInformation).

At the moment it supports sliders, ComboBoxes and RadioButtonGroups (any buttons supporting toggleState).

Let me know, if you find any errors, improvments or any feedback is welcome.

It was inspired by this conversation:

Correct way to connect ValueTree to Components created at runtime?

cool stuff. I hacked together a similar thing for a Label, if you’d like to add it to your repo

ValueTreeLabelAttachment.txt (4.5 KB)


Hi @olilarkin, that’s great. I added it and did an example in the playground there…
cool is also, with your labelAttachment you can change even items in a combobox, if you attach it to the same node…
Great addition, thanks again


Hi @daniel, is your code still up to date?
I am working on a simple plugin (learning things) and just “switched” to AudioProcessorValueTreeState to manage the state. I really like the approach, but now, like others, I find myself wondering what to do with radio buttons. I did some search on the forum and ended up here. Since it’s been some time since it was discussed, I was just wondering if there’s been any change/update in the meanwhile (advice, best practices etc.).
Thank you!


@dave96’s ADC’17 talk is must watch on this topic IMHO


Hi @Daniele, I haven’t touched the project I used it in a while, but I don’t see a reason why it shouldn’t work any more.

For single components like ComboBoxes and Sliders there are now alternative methods built into JUCE, e.g. getting Slider::getValueObject() and the value in the ValueTree using ValueTree::getPropertyAsValue() and link them using Value::referTo(), that way you don’t need to store an attachment and you don’t need to care about what is destroyed when.

For RadioGroups I think this approach is still the easiest. There is a snipped directly in the sources, in Line 49ff it is assembled and connected in Line 89:

buttonGroupAttachment = new ValueTreeRadioButtonGroupAttachment (select, btns, "name", true);

TBH, this example code is horrible in my todays perspective, I would write it quite differently today :wink: but it shows how it can be used…


Thanks for the advice @daniel!

Eventually, for this particular case, I think I am now more inclined towards a combo box rather then a radio group; the only reason for that is because there’s builtin support for it and, at this stage, I’d like to keep things as simple/short as possible (I am rather new to JUCE).

However I definitely see myself wanting to use radio groups at some point (whether in this or next project), so it’s good to know your solution is still relevant - I’ll definitely give it a go!