# Connect Combobox object to ValueTreeState

**URL:** <https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534>\
**Category:** General JUCE discussion\
**Created:** [October 3, 2019, 2:24pm UTC](https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534 "2019-10-03T14:24:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Campestring](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Campestring](https://forum.juce.com/u/Campestring)\
**Post date:** [October 3, 2019, 2:24pm UTC](https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534/1 "2019-10-03T14:24:01Z")

</div>

hello everyone,  
I don’t understand how to connect my Combobox to the valuetreestate,  
I already know how to connect a slider using SliderAttachement, I have Seen that there is a ComboboxAtachemment but I don’t really know how to do it and what write in my parameters.  
Thank you !

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [October 3, 2019, 2:30pm UTC](https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534/2 "2019-10-03T14:30:36Z")

</div>

It works best with AudioParameterChoice:

```auto
auto parameter = std::make_unique<AudioParameterChoice> ("foo", "Foo", StringArray ("foo", "bar", "baz"), 0);

```

```auto
new AudioProcessorValueTreeState::ComboBoxAttachment (processor.tree, "foo", combo);

```

Edited typo

---

<div class="post-metadata">

**Author:** ![Campestring](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Campestring](https://forum.juce.com/u/Campestring)\
**Post date:** [October 3, 2019, 4:16pm UTC](https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534/3 "2019-10-03T16:16:13Z")

</div>

hello and thank you for you reply !  
std::make\_unique(“filterType”,  
“FilterType”,  
StringArray(“Low pass”,“High Pass”)  
I initialise in my parameters like that but I have an error that the AudioParameterChoice desn’t have constructor with three parameters,  
I have that in my processor editor : AudioProcessorValueTreeState::ComboBoxAttachment \*filterTypeAttachement;  
and that into the constructor : filterTypeAttachement = new AudioProcessorValueTreeState::ComboBoxAttachment(valueTreeState, “filterType”, filterType);

But I don’t know if it’s wrong…  
and I have another question about when I have connected everything what kind of variable I have to associate with the getRawValue(filterType) ?  
thank you !

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [October 3, 2019, 4:47pm UTC](https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534/4 "2019-10-03T16:47:13Z")

</div>

Oh sorry, the default is also mandatory, I should have checked the [docs](https://docs.juce.com/develop/classAudioParameterChoice.html#ad310ba5b5749d8022acbe91cf90ed672).

The getRawParameterValue is the unnormalised, so if you do a `roundToInt (value)` it is the index in your StringArray…

I’ll edit the line above

---

<div class="post-metadata">

**Author:** ![Campestring](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@Campestring](https://forum.juce.com/u/Campestring)\
**Post date:** [October 3, 2019, 7:39pm UTC](https://forum.juce.com/t/connect-combobox-object-to-valuetreestate/35534/5 "2019-10-03T19:39:31Z")

</div>

Thank you I will try tomorrow but I don’t really understant the type of pointer I should déclare to do the getrawvalue ! Could you help me ?  
Thanks !
