diff --git a/modules/juce_gui_basics/buttons/juce_Button.cpp b/modules/juce_gui_basics/buttons/juce_Button.cpp index 65684a2d3d..95a3a60703 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.cpp +++ b/modules/juce_gui_basics/buttons/juce_Button.cpp @@ -47,7 +47,7 @@ struct Button::CallbackHelper : public Timer, void valueChanged (Value& value) override { if (value.refersToSameSourceAs (button.isOn)) - button.setToggleState (button.isOn.getValue(), dontSendNotification); + button.setToggleState (button.isOn.getValue(), dontSendNotification, sendNotification); } bool keyPressed (const KeyPress&, Component*) override @@ -132,7 +132,7 @@ void Button::updateAutomaticTooltip (const ApplicationCommandInfo& info) } } -void Button::setConnectedEdges (const int newFlags) +void Button::setConnectedEdges (int newFlags) { if (connectedEdgeFlags != newFlags) { @@ -142,7 +142,12 @@ void Button::setConnectedEdges (const int newFlags) } //============================================================================== -void Button::setToggleState (const bool shouldBeOn, const NotificationType notification) +void Button::setToggleState (bool shouldBeOn, NotificationType notification) +{ + setToggleState (shouldBeOn, notification, notification); +} + +void Button::setToggleState (bool shouldBeOn, NotificationType clickNotification, NotificationType stateNotification) { if (shouldBeOn != lastToggleState) { @@ -150,7 +155,7 @@ void Button::setToggleState (const bool shouldBeOn, const NotificationType notif if (shouldBeOn) { - turnOffOtherButtonsInGroup (notification); + turnOffOtherButtonsInGroup (clickNotification, stateNotification); if (deletionWatcher == nullptr) return; @@ -169,10 +174,10 @@ void Button::setToggleState (const bool shouldBeOn, const NotificationType notif lastToggleState = shouldBeOn; repaint(); - if (notification != dontSendNotification) + if (clickNotification != dontSendNotification) { // async callbacks aren't possible here - jassert (notification != sendNotificationAsync); + jassert (clickNotification != sendNotificationAsync); sendClickMessage (ModifierKeys::getCurrentModifiers()); @@ -180,19 +185,19 @@ void Button::setToggleState (const bool shouldBeOn, const NotificationType notif return; } - if (notification != dontSendNotification) + if (stateNotification != dontSendNotification) sendStateMessage(); else buttonStateChanged(); } } -void Button::setToggleState (const bool shouldBeOn, bool sendChange) +void Button::setToggleState (bool shouldBeOn, bool sendChange) { setToggleState (shouldBeOn, sendChange ? sendNotification : dontSendNotification); } -void Button::setClickingTogglesState (const bool shouldToggle) noexcept +void Button::setClickingTogglesState (bool shouldToggle) noexcept { clickTogglesState = shouldToggle; @@ -208,18 +213,18 @@ bool Button::getClickingTogglesState() const noexcept return clickTogglesState; } -void Button::setRadioGroupId (const int newGroupId, NotificationType notification) +void Button::setRadioGroupId (int newGroupId, NotificationType notification) { if (radioGroupId != newGroupId) { radioGroupId = newGroupId; if (lastToggleState) - turnOffOtherButtonsInGroup (notification); + turnOffOtherButtonsInGroup (notification, notification); } } -void Button::turnOffOtherButtonsInGroup (const NotificationType notification) +void Button::turnOffOtherButtonsInGroup (NotificationType clickNotification, NotificationType stateNotification) { if (auto* p = getParentComponent()) { @@ -235,7 +240,7 @@ void Button::turnOffOtherButtonsInGroup (const NotificationType notification) { if (b->getRadioGroupId() == radioGroupId) { - b->setToggleState (false, notification); + b->setToggleState (false, clickNotification, stateNotification); if (deletionWatcher == nullptr) return; @@ -259,7 +264,7 @@ Button::ButtonState Button::updateState() return updateState (isMouseOver (true), isMouseButtonDown()); } -Button::ButtonState Button::updateState (const bool over, const bool down) +Button::ButtonState Button::updateState (bool over, bool down) { ButtonState newState = buttonNormal; @@ -275,7 +280,7 @@ Button::ButtonState Button::updateState (const bool over, const bool down) return newState; } -void Button::setState (const ButtonState newState) +void Button::setState (ButtonState newState) { if (buttonState != newState) { @@ -303,7 +308,7 @@ uint32 Button::getMillisecondsSinceButtonDown() const noexcept return now > buttonPressTime ? now - buttonPressTime : 0; } -void Button::setTriggeredOnMouseDown (const bool isTriggeredOnMouseDown) noexcept +void Button::setTriggeredOnMouseDown (bool isTriggeredOnMouseDown) noexcept { triggerOnMouseDown = isTriggeredOnMouseDown; } @@ -519,8 +524,8 @@ void Button::parentHierarchyChanged() } //============================================================================== -void Button::setCommandToTrigger (ApplicationCommandManager* const newCommandManager, - const CommandID newCommandID, const bool generateTip) +void Button::setCommandToTrigger (ApplicationCommandManager* newCommandManager, + CommandID newCommandID, bool generateTip) { commandID = newCommandID; generateTooltip = generateTip; @@ -640,9 +645,9 @@ bool Button::keyPressed (const KeyPress& key) } //============================================================================== -void Button::setRepeatSpeed (const int initialDelayMillisecs, - const int repeatMillisecs, - const int minimumDelayInMillisecs) noexcept +void Button::setRepeatSpeed (int initialDelayMillisecs, + int repeatMillisecs, + int minimumDelayInMillisecs) noexcept { autoRepeatDelay = initialDelayMillisecs; autoRepeatSpeed = repeatMillisecs; diff --git a/modules/juce_gui_basics/buttons/juce_Button.h b/modules/juce_gui_basics/buttons/juce_Button.h index ca8c1332f7..edea4b7a02 100644 --- a/modules/juce_gui_basics/buttons/juce_Button.h +++ b/modules/juce_gui_basics/buttons/juce_Button.h @@ -509,11 +509,12 @@ private: ButtonState updateState(); ButtonState updateState (bool isOver, bool isDown); bool isShortcutPressed() const; - void turnOffOtherButtonsInGroup (NotificationType); + void turnOffOtherButtonsInGroup (NotificationType click, NotificationType state); void flashButtonState(); void sendClickMessage (const ModifierKeys&); void sendStateMessage(); + void setToggleState (bool shouldBeOn, NotificationType click, NotificationType state); bool isMouseOrTouchOver (const MouseEvent& e);