surge-synthesizer / surge

Synthesizer plug-in (previously released as Vember Audio Surge)
https://surge-synthesizer.github.io/
GNU General Public License v3.0
3.03k stars 387 forks source link

Accessible focus from menus on Windows #6426

Open baconpaul opened 1 year ago

baconpaul commented 1 year ago

Conversation with x0 (@ultrasound1372 ) and @pitermach on discord today

x0:

Okay re focus out of menus thing. Whether pressing escape or enter it does leave me in limbo most of the time until I tab, at which point it brings me back to where it was. Asking NVDA for info on the focused object after doing this gives no message at all. Opening the log viewer to look at developer info for the current navigator gives this exception text for states, is focusable, UIA automation ID, and UIA className. Exception: (-2147220991, 'An event was unable to invoke any of the subscribers', (None, None, None, 0, None)) The location is said to be a rectangle of nothing, I.E. left/top coordinates are 0, and width/height are 0, has no name, role is a window, window class name is JUCE_1823b9a25ef, and control ID, style and extended style are 0. It looks like some kind of dummy object. This is the info on the limbo object that I end up landed on, not the object after hitting tab obviously.

What's interesting is that pressing tab again brings you to the last control that was focused, not the one after it in the order like you'd expect. Which means your tracking does work. So patching on menu close to basically simulate some of the things tab does would likely be enough.

baconpaul yeah so I think @pitermach gets it right: The focus stays on the vanished menu on close even though the next focused object is the original slider. If a sighted user could use the UI on windows with the focus debugger and try escaping out of a menu, that might help

x0 I need to test something actually... The way NVDA acts is as if the menu pops a separate top-level window, which then disappears afterwards. It possibly doesn't get notified of that disappearance... My evidence for this is that when activating a menu it goes Surge XT again as if it were reporting a window title change. Focus issues are common when things only visually, and not logically, overlay other things. Indeed @pitermach is correct, when I press enter on a menu to, say, pick an oscillator type and end up in limbo where navigation commands don't work, the log viewer shows that the supposed object with focus has a role of menu item, and throws all those exceptions. I assume window is what you get when you hit escape. Perhaps there's some kind of destroy event that Juce doesn't call within its menus? An event that says hey, this object is now gone. Find another.

baconpaul commented 1 year ago

pitermach says:

If the Juce devs need help debugging UIA issues like this, it's probably worth asking Leonard de Ruijter (leonardder on github). He's responsible for much of NVDA's UIA modernisation and OSARA's UIA support he knows his way around it very well

pitermach commented 1 year ago

After a conversation with another user on Discord I think this issue is on Mac OS as well, but manifests itself differently, and only if Surge is running as a plugin and not standalone. Here are some Mac reproduction steps:

After the menu is closed, VoiceOver should focus and announce the oscillator type button since that's where the keyboard focus is. What ends up happening here is that VoiceOver thinks the focus has jumped back to a control in the main Reaper window, and you can verify this by pressing CTRL+option+F4 to have VO speak where it thinks the keyboard focus is. Now because the VO cursor and keyboard focus are supposed to always be in sync if you now try to move around with VOiceOver's navigation keys, you'll get kicked out of Surge and start moving through Reaper's interface, but if you instead tab immediately after closing the menu VoiceOver's cursor will return to the Surge window where it should be.

Interestingly enough sometimes this issue doesn't appear but I haven't been able to figure out what causes it to work correctly. I know that after you load a copy of Surge or close and reopen Reaper's FX window it occurs 100% of the time.

I was also able to reproduce this in other Juce plugins that pop up menus like ChowTape and Audiothing Noises, so I think there's definitely a Juce bug here.