# Containing toggle button state cascade

**URL:** <https://forum.juce.com/t/containing-toggle-button-state-cascade/69875>\
**Category:** General JUCE discussion\
**Created:** [November 9, 2026, 10:54am UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875 "2026-11-09T10:54:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![enigemic-sounds](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/enigemic-sounds/32/22070_2.png) [@enigemic-sounds](https://forum.juce.com/u/enigemic-sounds)\
**Post date:** [November 9, 2026, 10:54am UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/1 "2026-11-09T10:54:11Z")

</div>

I’m working on a plugin that can either sync several parameters with the DAW or let the user choose their own values, controlled by a few toggle buttons. A simplified version is (imagine these are buttons)

```auto
[ALL] [X] [Y] [Z]

```

XYZ are things like BPM, time signature, etc…

The behaviour I currently have working OK is:

1. if the user toggles [ALL] on then [XYZ] get all toggled on
2. if the user toggles one non-[ALL] button off, then [ALL] is toggled off
3. if the user toggling one of [XYZ] makes all 3 be on, then [ALL] gets toggled on

I would also like to implement that if the user toggles [ALL] off then all the rest get toggled off (ie. the opposite of 1)

My code looks something like

```cpp
void ButtonArea::buttonClicked(juce::Button* button) {
{
    if ( button == &syncAllToggle ) {
        if ( syncAllToggle.getToggleState() ) {
            syncXToggle.setToggleState( true, juce::sendNotification );
            syncYToggle.setToggleState( true, juce::sendNotification );
            syncZToggle.setToggleState( true, juce::sendNotification );
// return;
    }
// syncXToggle.setToggleState( false, juce::sendNotification );
// syncYToggle.setToggleState( false, juce::sendNotification );
// syncZToggle.setToggleState( false, juce::sendNotification );
    } else if ( !button->getToggleState() ) {
        syncAllToggle.setToggleState( false, juce::sendNotification );
    } else if ( syncXToggle.getToggleState() &&
                syncYToggle.getToggleState() &&
                syncZToggle.getToggleState() ) {
        syncAllToggle.setToggleState( true, juce::sendNotification );
    }
}

```

The problem I have with my approach is that the buttons are tied to `Value`s and APVTS params, so I need to send a notification when using `setToggleState`, but that calls `clicked`.

If I uncomment the code above, when the user toggles one of [XYZ] off, [ALL] gets toggled off which in turns all remaining buttons off.

The closest I’ve got is by not sending a notification in the first `else if`, but then that doesn’t get picked up by the APVTS so the host doesn’t write it to the state and when the plugin restarts the buttons will be in an invalid combo (i.e. [ALL] will be on but one of [XYZ] is off)

Being able to tell apart a programmatic toggle from a “real” user click would be ideal but I don’t know if there’s a way to do it, or how others have solved this?

TIA

Edit: Also tried the solution mentioned [here](https://forum.juce.com/t/buttonparameterattachment-and-button-notification-bug/56143/16) but it’s the same as not sending the notification i.e. it’s not saved in the APVTS.

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [November 9, 2026, 11:20am UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/2 "2026-11-09T11:20:29Z")

</div>

don’t use four bool but an int and the UI just display those as buttons ?

---

<div class="post-metadata">

**Author:** ![enigemic-sounds](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/enigemic-sounds/32/22070_2.png) [@enigemic-sounds](https://forum.juce.com/u/enigemic-sounds)\
**Post date:** [November 9, 2026, 11:30am UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/3 "2026-11-09T11:30:43Z")

</div>

could you elaborate a bit please?

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [November 9, 2026, 12:11pm UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/4 "2026-11-09T12:11:51Z")

</div>

you should have only one parameter as an enum instead of four parameters

---

<div class="post-metadata">

**Author:** ![enigemic-sounds](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/enigemic-sounds/32/22070_2.png) [@enigemic-sounds](https://forum.juce.com/u/enigemic-sounds)\
**Post date:** [November 9, 2026, 12:19pm UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/5 "2026-11-09T12:19:45Z")

</div>

I don’t follow how that would solve the problem

do you mean behaviour like [ConnectedEdgeFlags](https://docs.juce.com/master/classjuce_1_1Button.html#a9d07bf49de59e41ec37abc3ffd93298a)?

---

<div class="post-metadata">

**Author:** ![otristan](https://avatars.discourse-cdn.com/v4/letter/o/f0a364/32.png) [@otristan](https://forum.juce.com/u/otristan)\
**Post date:** [November 9, 2026, 12:33pm UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/6 "2026-11-09T12:33:37Z")

</div>

that way you juste have one parameter that you have and each button are set with using notification.

---

<div class="post-metadata">

**Author:** ![rcohen](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@rcohen](https://forum.juce.com/u/rcohen)\
**Post date:** [November 9, 2026, 1:44pm UTC](https://forum.juce.com/t/containing-toggle-button-state-cascade/69875/7 "2026-11-09T13:44:39Z")

</div>

In addition to using a single parameter, you might place the buttons in a RadioGroup
