From 63d15b1fb6f8622363fadb5037fca26a5b8102b5 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 7 Jan 2025 10:18:45 -0500 Subject: [PATCH] Add more correct key bindings to ToggleButton accessible --- src/sst/jucegui/components/ToggleButton.cpp | 52 ++++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/sst/jucegui/components/ToggleButton.cpp b/src/sst/jucegui/components/ToggleButton.cpp index a8ea132..b4aaba6 100644 --- a/src/sst/jucegui/components/ToggleButton.cpp +++ b/src/sst/jucegui/components/ToggleButton.cpp @@ -187,14 +187,52 @@ void ToggleButton::mouseUp(const juce::MouseEvent &e) bool ToggleButton::keyPressed(const juce::KeyPress &e) { - if (e.getKeyCode() == juce::KeyPress::returnKey && data) + if (data) { - onBeginEdit(); - data->setValueFromGUI(!data->getValue()); - notifyAccessibleChange(); - repaint(); - onEndEdit(); - return true; + auto a = accessibleEdit(e); + switch (a.action) + { + case Action::Increase: + case Action::ToMax: + { + onBeginEdit(); + data->setValueFromGUI(data->getMax()); + notifyAccessibleChange(); + repaint(); + onEndEdit(); + return true; + } + break; + case Action::Decrease: + case Action::ToMin: + { + onBeginEdit(); + data->setValueFromGUI(data->getMin()); + notifyAccessibleChange(); + repaint(); + onEndEdit(); + return true; + } + break; + case Action::ToDefault: + { + onBeginEdit(); + data->setValueFromGUI(data->getDefaultValue()); + notifyAccessibleChange(); + repaint(); + onEndEdit(); + return true; + } + break; + case Action::OpenMenu: + { + showPopup({}); + return true; + } + break; + default: + break; + } } return false; }