# Can I put a TextButton in the APVTS, and access its toggle state?

**URL:** <https://forum.juce.com/t/can-i-put-a-textbutton-in-the-apvts-and-access-its-toggle-state/54954>\
**Category:** General JUCE discussion\
**Created:** [February 11, 2023, 4:02pm UTC](https://forum.juce.com/t/can-i-put-a-textbutton-in-the-apvts-and-access-its-toggle-state/54954 "2023-02-11T16:02:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TrustedSteed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/trustedsteed/32/13862_2.png) [@TrustedSteed](https://forum.juce.com/u/TrustedSteed)\
**Post date:** [February 11, 2023, 4:02pm UTC](https://forum.juce.com/t/can-i-put-a-textbutton-in-the-apvts-and-access-its-toggle-state/54954/1 "2023-02-11T16:02:39Z")

</div>

I’ve got an APVTS structure with a number of `SliderAttachment` entries for my knobs.  
I want to add a TextButton. I’ve set this clicking toggle state to `true`.

How do I add this TextButton to my APVTS, and can I use `getRawParameterValue` to find its toggle state?

Here’s what I have so far:

PluginEditor.h

```auto
juce::TextButton mybutton_button;
juce::AudioProcessorValueTreeState::ButtonAttachment mybutton_buttonAttachment;

```

In PluginEditor.cpp

```auto
	mybutton_button.setButtonText("my button text");
	mybutton_button.setClickingTogglesState(true);
	addAndMakeVisible(mybutton_button);

```

PluginEditor Constructor:  
`	mybutton_buttonAttachment(audioProcessor.apvts, "mybutton", mybutton_button) {`

In PluginProcessor.cpp  
`mybutton_value = apvts.getRawParameterValue("mybutton")->load();`

for my sliders, I am adding them to the layout with `createParameterLayout()`. I think I can’t add the mybutton attachment here… … or can I 🤔

---

<div class="post-metadata">

**Author:** ![nfect](https://avatars.discourse-cdn.com/v4/letter/n/a6a055/32.png) [@nfect](https://forum.juce.com/u/nfect)\
**Post date:** [February 12, 2023, 11:28pm UTC](https://forum.juce.com/t/can-i-put-a-textbutton-in-the-apvts-and-access-its-toggle-state/54954/2 "2023-02-12T23:28:15Z")

</div>

I may be mistaken, but you’d add mybutton\_button to the layout, not the attachment, but I believe if you could add slider attachement, you could do the same with buttons.

---

<div class="post-metadata">

**Author:** ![TrustedSteed](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/trustedsteed/32/13862_2.png) [@TrustedSteed](https://forum.juce.com/u/TrustedSteed)\
**Post date:** [February 13, 2023, 6:36pm UTC](https://forum.juce.com/t/can-i-put-a-textbutton-in-the-apvts-and-access-its-toggle-state/54954/3 "2023-02-13T18:36:48Z")

</div>

In the end I was able to put it in the parameterLayout.  
`layout.add(std::make_unique<juce::AudioParameterBool>("mybutton", "my button text", false));`  
Seems to work.
