Skip to content

Commit 150f7c5

Browse files
committed
Button: Make setToggleState effective even when disabled
This commit partially reverts 07f8011. While it's justifiable that triggerClick() is guarded and ineffective when the button is disabled, setToggleState() needs to work to correctly represent the underlying parameter state.
1 parent 8ab6c3b commit 150f7c5

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

modules/juce_gui_basics/buttons/juce_Button.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void Button::setToggleState (bool shouldBeOn, NotificationType notification)
171171

172172
void Button::setToggleState (bool shouldBeOn, NotificationType clickNotification, NotificationType stateNotification)
173173
{
174-
if (isEnabled() && shouldBeOn != lastToggleState)
174+
if (shouldBeOn != lastToggleState)
175175
{
176176
WeakReference<Component> deletionWatcher (this);
177177

modules/juce_gui_basics/detail/juce_ButtonAccessibilityHandler.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,16 @@ class ButtonAccessibilityHandler : public AccessibilityHandler
111111
[&button] { button.triggerClick(); });
112112

113113
if (button.isToggleable())
114+
{
114115
actions = actions.addAction (AccessibilityActionType::toggle,
115-
[&button] { button.setToggleState (! button.getToggleState(), sendNotification); });
116+
[&button]
117+
{
118+
if (! button.isEnabled())
119+
return;
120+
121+
button.setToggleState (! button.getToggleState(), sendNotification);
122+
});
123+
}
116124

117125
return actions;
118126
}

0 commit comments

Comments
 (0)