Skip to content

Commit

Permalink
Add more correct key bindings to ToggleButton accessible
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Jan 7, 2025
1 parent 86e1174 commit 63d15b1
Showing 1 changed file with 45 additions and 7 deletions.
52 changes: 45 additions & 7 deletions src/sst/jucegui/components/ToggleButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 63d15b1

Please sign in to comment.