mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Accessibility: Report Button on/off state via AccessibilityValueInterface
This commit is contained in:
parent
e6360ca4cf
commit
0000771751
1 changed files with 29 additions and 1 deletions
|
|
@ -722,7 +722,8 @@ public:
|
|||
explicit ButtonAccessibilityHandler (Button& buttonToWrap, AccessibilityRole roleIn)
|
||||
: AccessibilityHandler (buttonToWrap,
|
||||
isRadioButton (buttonToWrap) ? AccessibilityRole::radioButton : roleIn,
|
||||
getAccessibilityActions (buttonToWrap)),
|
||||
getAccessibilityActions (buttonToWrap),
|
||||
getAccessibilityInterfaces (buttonToWrap)),
|
||||
button (buttonToWrap)
|
||||
{
|
||||
}
|
||||
|
|
@ -755,6 +756,25 @@ public:
|
|||
String getHelp() const override { return button.getTooltip(); }
|
||||
|
||||
private:
|
||||
class ButtonValueInterface : public AccessibilityTextValueInterface
|
||||
{
|
||||
public:
|
||||
explicit ButtonValueInterface (Button& buttonToWrap)
|
||||
: button (buttonToWrap)
|
||||
{
|
||||
}
|
||||
|
||||
bool isReadOnly() const override { return true; }
|
||||
String getCurrentValueAsString() const override { return button.getToggleState() ? "On" : "Off"; }
|
||||
void setValueAsString (const String&) override {}
|
||||
|
||||
private:
|
||||
Button& button;
|
||||
|
||||
//==============================================================================
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ButtonValueInterface)
|
||||
};
|
||||
|
||||
static bool isRadioButton (const Button& button) noexcept
|
||||
{
|
||||
return button.getRadioGroupId() != 0;
|
||||
|
|
@ -772,6 +792,14 @@ private:
|
|||
return actions;
|
||||
}
|
||||
|
||||
static Interfaces getAccessibilityInterfaces (Button& button)
|
||||
{
|
||||
if (button.isToggleable())
|
||||
return { std::make_unique<ButtonValueInterface> (button) };
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Button& button;
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue