There’s currently no reliable way to know when a particular component has lost accessibility focus.
The focusGained
and focusLost
methods of juce::Component
do sometimes work, but they’re unreliable (I believe they rely on the component also receiving keyboard focus when focused by an accessibility client).
The AccessibilityHandler
does have a focus
action type, but this is only used for focus gain, whereas we’d like to have an action for focus lost as well.
Simplest solution would likely be to add a focusLost
action to juce::AccessibilityActionType
. It would also be nice if juce::Component::FocusChangeType
had a focusChangedByScreenreader
option and the focusGained
and focusLost
methods of juce::Component
can be used for this purpose (which means we don’t need to create a whole new custom accessibility handler just to know about focus changes).
Our particular use-case is a button that’s positioned over an indicator that only becomes visible when the mouse is hovered-over. With a screenreader, the button is perfectly functional, but it remains always invisible - this isn’t ideal as some users who use a screenreader are sighted, and those that aren’t are often working alongside a sighted user and so it’s important that the button has the same behaviour when focused with a screenreader as it does when hovered with the mouse.
Right now we can make the button visible when focus is gained, but there’s no way to know when to make the button invisible again on focus lost (without hacky work-arounds).