VoiceOver for macOS: how to set the initially focused element for a view controller?

541 views Asked by At

How does one set the initially focused VoiceOver element after transitioning from one view controller to the next?

I'm asking this as a macOS follow-up to this answer for iOS: VoiceOver: force an accessibility element to be selected after a screen transition

1

There are 1 answers

0
Nick K9 On

VoiceOver follows the the keyboard focus which is set using NSWindow.makeFirstResponder(_:). So you just need to set a first responder once the view controller has loaded, and VoiceOver will move to it and speak it.

Unfortunately, this is limited to elements which accept first responder, which leaves out many VoiceOver elements. On macOS, there is not presently a way to set the VoiceOver cursor on arbitrary elements in the accessibility hierarchy. If you can't set the VoiceOver cursor where you want, an alternative may be to speak a VoiceOver notification to orient your users to the new screen context.