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.
This commit is contained in:
Nolan Darilek 2020-08-10 13:26:57 -05:00
parent c218d18090
commit 54c01c5381
2 changed files with 6 additions and 2 deletions

View File

@ -54,7 +54,7 @@ func _guess_label():
func _accept_dialog_speak(): func _accept_dialog_speak():
if node.dialog_text != "": if node.dialog_text != "":
TTS.speak("dialog: %s" % node.dialog_text) TTS.speak("dialog: %s" % node.dialog_text, false)
func accept_dialog_focused(): func accept_dialog_focused():
@ -66,6 +66,7 @@ func accept_dialog_focused():
func _accept_dialog_about_to_show(): func _accept_dialog_about_to_show():
_accept_dialog_speak() _accept_dialog_speak()
ScreenReader.should_stop_on_focus = false
func checkbox_focused(): func checkbox_focused():
@ -543,7 +544,9 @@ func tab_container_input(event):
func focused(): func focused():
print_debug("Focus: %s" % node) 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: if not node is Label:
var label = _guess_label() var label = _guess_label()
if label: if label:

View File

@ -21,6 +21,7 @@ export var explore_by_touch_interval = 200
export var enable_focus_mode = false export var enable_focus_mode = false
var should_stop_on_focus = true
func _set_enabled(v): func _set_enabled(v):
if enabled: if enabled: