Hi!
This is less of a question and more of a comment, really.
We have a custom toggle button class in Surge and I implemented accessibility for it roughly how you would expect
explicit SwitchAH(Switch *s)
: mswitch(s), juce::AccessibilityHandler(
*s,
s->isMultiIntegerValued() ? juce::AccessibilityRole::button
: juce::AccessibilityRole::toggleButton,
juce::AccessibilityActions()
.addAction(juce::AccessibilityActionType::showMenu,
[this]() { this->showMenu(); })
.addAction(juce::AccessibilityActionType::press,
[this]() { this->press(); }))
{
}
juce::AccessibleState getCurrentState() const override
{
auto state = AccessibilityHandler::getCurrentState();
state = state.withCheckable();
if (mswitch->getValue() > 0.5)
state = state.withChecked();
return state;
}
This worked great on macOS, but on windows it reported no errors or concerns, but didn’t show a value. The reason, which you may see, is that I don’t implement the ::toggle action.
In juce_win32_AccesibilityElement.cpp you see this
case UIA_TogglePatternId:
{
if (accessibilityHandler.getActions().contains (AccessibilityActionType::toggle)
&& accessibilityHandler.getCurrentState().isCheckable())
{
return new UIAToggleProvider (this);
}
break;
}
which explains why it didn’t work; if you don’t implement :toggle then no accessible value.
But
1: Toggle doesn’t shine through as an event in mac accesibility inspector and
2: I “am” a toggleButton role
So I think that maybe this condition is wrong, but if it isn’t for some reason (I didn’t dig too far into the UIAToggleProvider) it would have been super awesome for the AH to have something like
if (role == toggleButton && ! actions.contain(::toggle))
// comment comment
jassert(false)
so I could have at least known it wouldn’t work on windows after writing it on mac.
Anyway nothing beats testing and we found this and I added the ::toggle method but just wanted to share this experience in case either (1) @reuk you would consider such an assertion and if you can’t for some reason (2) someone else could find this in the future
Surge Accessibility is looking really good and looks like we will be able to release next week or thereabouts. Exciting!