Please pardon if this is a noob question. I only saw one other forum post slightly related.
I can successfully save/restore the states of Sliders, ComboBoxes persistently using AudioProcessorValueTreeState.
My issue is that I also have a group of radio buttons, and I would like to save/restore a single integer value (which button is selected).
Just adding a parameter to AudioProcessorValueTreeState doesn’t really work. I can’t change its value and save/restore doesn’t work.
If I attach that parameter to an “invisible slider” (not painted on the UI), everything works well. A few lines of code translates the “invisible slider” attached parameter value to/from the selected radio button.
I guess AudioProcessorValueTreeState is made to handle / depends on UI control states only? Maybe a generic ValueTree could be used alongside it for non-control parameters. Integration seems messy, not sure I could manage it.
So I have a working solution/workaround. It seems a bit of a kluge. Is there a more standard/elegant way to achieve this?
Thanks.
You can use a juce::ParameterAttachment to make the connection between the integer parameter and the radio buttons. The other attachments (ButtonParameterAttachment, SliderAttachment etc) use such a ParameterAttachment object to do most of the work. Look at the code for ButtonParameterAttachment to see how to hook a ParameterAttachment up to your own UI controls.
Thanks @kerfuffle .
I plan to do a little experiment, to educate myself.
(I’m currently a happy JUCE hobbyist, although a retired programmer.)
If I come up with something great and reusable, I can put it on my shelf and maybe share.
Logically, it seems to me that the behavior I want (on the programming/data side) is almost exactly like a ComboBox. The controls/widgets at the UI level are different.
Creating a completely new type of UI control at all levels looks like a lot of work. I will go down the path of investigating how much I can reuse from ComboBox (and existing Button code).
(My crude approach would have been better if I had chosen a ComboBox rather than a Slider.)
I recently uploaded an example of using ParameterAttachment for exactly this purpose:
Hopefully that’s a useful example. 
Thanks again @kerfuffle . I will study it. Your example’s approach is much more elegant than mine.
For fun I created a “myjuce::RadioComboBox” class (a little wrapper/glue around embedded juce::ComboBox) and it also seems to work as I want. It imitates a subset of the ComboBox interface (more or less). Fairly small and straightforward. At least cleaner and more reusable than my first attempt.