From 56a7652656ca781e49de1a631edae76b7f1aa9b3 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 17 Sep 2019 10:42:58 -0500 Subject: [PATCH] Assorted changes: * Use new TTS.gd script rather than loading directly. TTS.gd gives us flexibility to handle TTS with the native Rust plugin on some platforms, something like a Java module under Android, etc. * Make `Panel` focusable. This handles the case where exiting a game from the editor places focus on an element without focus, thus breaking keyboard navigation. * Log when we attempt to grab focus so I can debug cases where focus tries to go somewhere it can't. --- accessibility.gd | 3 ++- accessible.gd | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/accessibility.gd b/accessibility.gd index 4276f48..e81d733 100644 --- a/accessibility.gd +++ b/accessibility.gd @@ -3,7 +3,8 @@ extends EditorPlugin var Accessible = preload("accessible.gd") -const TTS = preload("res://addons/godot-tts/godot-tts.gdns") +var TTS = preload("../godot-tts/TTS.gd") + var tts func augment_node(node): diff --git a/accessible.gd b/accessible.gd index a7e8e1f..ca379e9 100644 --- a/accessible.gd +++ b/accessible.gd @@ -168,6 +168,9 @@ func menu_button_focus(): tokens.append("menu") tts.speak(tokens.join(": "), false) +func panel_focus(): + tts.speak("panel", true) + func popup_menu_focus(): tts.speak("menu", false) @@ -354,6 +357,8 @@ func focused(): label_focus() elif node is LineEdit: line_edit_focus() + elif node is Panel: + panel_focus() elif node is PopupMenu: popup_menu_focus() elif node is TabContainer: @@ -375,6 +380,7 @@ func unfocused(): func click_focused(): if node.has_focus(): return + print("Grabbing focus: %s" % node) node.grab_focus() func gui_input(event): @@ -413,7 +419,7 @@ func is_focusable(node): return true if node.get_class() == "EditorInspectorSection": return true - if node is Container or node is Panel or node is Separator or node is ScrollBar or node is Popup or node.get_class() == "Control": + if node is Container or node is Separator or node is ScrollBar or node is Popup or node.get_class() == "Control": return false return true