Any idea why my programatic action works under Linux but not Android?

nolannolan Posts: 19Member

I'm working on a Godot accessibility plugin that implements a GDScript-based screen reader for controls. Recently I started adding Android support, including support for touchscreen navigation and review. Screen readers have a somewhat different touch interaction model. Essentially, users can explore the screen with their finger, and focus remains on the last touched control. To tap something, a user can double-tap quickly anywhere on the screen, and the last focused control is tapped. Double-tapping substitutes for single-taps, which are assumed to be either exploration or a precursor to a swipe. Additionally, users can swipe quickly to the right or left to emulate Tab/Shift-tab, moving focus between controls without having to explore and find them.

I'm currently working on swipe navigation. I detect left and right swipes, and programatically generate and inject ui_focus_next or ui_focus_prev. It works well on the desktop, but fails completely under Android. More specifically, the swipe itself is correctly detected. But I then programatically generate a ui_focus_next or ui_focus_prev action and inject it, and that seems to have no effect under Android while it works fine under Linux. I also thought that maybe ui_focus_next wasn't available on Android for some reason, but plugging in a keyboard and pressing Tab showed that it was. Additionally, explicitly setting the next focusable property on Control (I forget the exact name) made no difference.

Here's my code for generating actions programatically. Is anything obviously wrong with it? Wondering if my created event may be missing some properties and is failing a sanity check somewhere. I also tried setting a device in case that mattered, but it doesn't appear to, or maybe I've set the wrong one? Anyhow, my code:

func press_and_release(action):
    var event = InputEventAction.new()
    event.action = action
    event.device = 0
    event.pressed = true
    get_tree().input_event(event)
    event.pressed = false
    get_tree().input_event(event)

Answers

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file