From cafd50675be3033785a0d862182f40652c40cc74 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 26 Sep 2019 08:10:48 -0500 Subject: [PATCH] Add group navigation. Moving through every focusable widget by tab/shift-tab is very slow. This commit introduces the concept of groups--widgets that can be skipped through via ctrl-tab/ctrl-shift-tab. Right now this only includes containers where all children are focusable, but I'll expand the definition of groups over time to make navingating to large areas of the UI easier.. --- Accessible.gd | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Accessible.gd b/Accessible.gd index 7929892..157f375 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -386,6 +386,8 @@ func focus(): print("No handler") if node.hint_tooltip and not spoke_hint_tooltip: tts.speak(node.hint_tooltip, false) + if is_in_group(): + tts.speak("group", false) spoke_hint_tooltip = false func unfocus(): @@ -425,8 +427,21 @@ func gui_input(event): return node.accept_event() elif event.is_action_pressed("ui_down"): return node.accept_event() + elif event is InputEventWithModifiers: + if Input.is_action_just_pressed("ui_focus_prev") and event.control and is_in_group(): + print("Prev") + var target = get_siblings()[0] + if target: + print("Got target") + target.grab_focus() + target.grab_click_focus() + elif Input.is_action_just_pressed("ui_focus_next") and event.control and is_in_group(): + var target = get_siblings()[-1] + if target: + target.grab_focus() + target.grab_click_focus() -func is_in_bar(): +func is_in_group(): var parent = node.get_parent() if parent and parent is Container: for child in parent.get_children():