From 54c01c53814fa484fb5b857cd95eeb67b350bd43 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 10 Aug 2020 13:26:57 -0500 Subject: [PATCH] Allow a global override to determine if the next focus event should interrupt speech. There seem to be a small handful of cases where we want this--controls that gain focus immediately after a dialog appears, for instance. We allow these edge cases to indicate that the next focus shouldn't stop speech, then clear it on cases where speech isn't stopped. This is a bit hacky, but seems cleaner than anything else I came up with. --- Accessible.gd | 7 +++++-- ScreenReader.gd | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Accessible.gd b/Accessible.gd index 12eb1f7..c0fafdc 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -54,7 +54,7 @@ func _guess_label(): func _accept_dialog_speak(): if node.dialog_text != "": - TTS.speak("dialog: %s" % node.dialog_text) + TTS.speak("dialog: %s" % node.dialog_text, false) func accept_dialog_focused(): @@ -66,6 +66,7 @@ func accept_dialog_focused(): func _accept_dialog_about_to_show(): _accept_dialog_speak() + ScreenReader.should_stop_on_focus = false func checkbox_focused(): @@ -543,7 +544,9 @@ func tab_container_input(event): func focused(): print_debug("Focus: %s" % node) - TTS.stop() + if ScreenReader.should_stop_on_focus: + TTS.stop() + ScreenReader.should_stop_on_focus = true if not node is Label: var label = _guess_label() if label: diff --git a/ScreenReader.gd b/ScreenReader.gd index 584a2a5..6f17edc 100644 --- a/ScreenReader.gd +++ b/ScreenReader.gd @@ -21,6 +21,7 @@ export var explore_by_touch_interval = 200 export var enable_focus_mode = false +var should_stop_on_focus = true func _set_enabled(v): if enabled: