comboBox and referTo() ValueTree


#1

hi there,
haw can I bind a ComboBox to a ValueTree with some Children.
F.E:
ValueTree
names
name value=“someName1”
name value=“someName2”
name value=“someName3”

so the combo box displays and reacts to changes in the ValueTree with referTo() and has the items:
someName1
someName2
someName3
thanks!


#2

There’s the AudioProcessorValueTreeState::ComboBoxAttachment class for doing this for plug-in parameters which it might be worth looking at, but it’s not very clear what you mean from your post - could you post some code to clarify what you’re trying to achieve?


#3

thanks! it is kinda of what I’m looking for. but I don’t want to use an AudioProcessor.
so I’m trying to referTo() a common ValueTree. but I’ll look on how it’s implemented in the AudioProcessorValueTreeState::ComboBoxAttachment.
greets


#4

I wrote something alike here:


#5

But there is also ComboBox::getSelectedIdAsValue() to do:

auto& value = tree.getPropertyAsValue ("combo", nullptr);
combo.getSelectedIdAsValue().referTo (value);

#6

thanks! I’ll look into your implementation.