From 062c85db12f8fa09c4388caf9c3892444c342546 Mon Sep 17 00:00:00 2001 From: jules Date: Wed, 13 Nov 2013 11:08:59 +0000 Subject: [PATCH] Changed the order in which radio-group toggle button events are sent, so that the "off" event is sent before the "on". --- .../juce_gui_basics/buttons/juce_Button.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index e996545680..44af5cde4f 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -165,14 +165,22 @@ void Button::setToggleState (const bool shouldBeOn, const NotificationType notif { if (shouldBeOn != lastToggleState) { + WeakReference deletionWatcher (this); + + if (shouldBeOn) + { + turnOffOtherButtonsInGroup (dontSendNotification); + + if (deletionWatcher == nullptr) + return; + } + if (getToggleState() != shouldBeOn) // this test means that if the value is void rather than explicitly set to isOn = shouldBeOn; // false, it won't be changed unless the required value is true. lastToggleState = shouldBeOn; repaint(); - WeakReference deletionWatcher (this); - if (notification != dontSendNotification) { // async callbacks aren't possible here @@ -184,14 +192,6 @@ void Button::setToggleState (const bool shouldBeOn, const NotificationType notif return; } - if (lastToggleState) - { - turnOffOtherButtonsInGroup (dontSendNotification); - - if (deletionWatcher == nullptr) - return; - } - if (notification != dontSendNotification) sendStateMessage(); }