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.
This commit is contained in:
Nolan Darilek 2019-09-17 10:42:58 -05:00
parent 40cb92d39b
commit 56a7652656
2 changed files with 9 additions and 2 deletions

View File

@ -3,7 +3,8 @@ extends EditorPlugin
var Accessible = preload("accessible.gd") var Accessible = preload("accessible.gd")
const TTS = preload("res://addons/godot-tts/godot-tts.gdns") var TTS = preload("../godot-tts/TTS.gd")
var tts var tts
func augment_node(node): func augment_node(node):

View File

@ -168,6 +168,9 @@ func menu_button_focus():
tokens.append("menu") tokens.append("menu")
tts.speak(tokens.join(": "), false) tts.speak(tokens.join(": "), false)
func panel_focus():
tts.speak("panel", true)
func popup_menu_focus(): func popup_menu_focus():
tts.speak("menu", false) tts.speak("menu", false)
@ -354,6 +357,8 @@ func focused():
label_focus() label_focus()
elif node is LineEdit: elif node is LineEdit:
line_edit_focus() line_edit_focus()
elif node is Panel:
panel_focus()
elif node is PopupMenu: elif node is PopupMenu:
popup_menu_focus() popup_menu_focus()
elif node is TabContainer: elif node is TabContainer:
@ -375,6 +380,7 @@ func unfocused():
func click_focused(): func click_focused():
if node.has_focus(): if node.has_focus():
return return
print("Grabbing focus: %s" % node)
node.grab_focus() node.grab_focus()
func gui_input(event): func gui_input(event):
@ -413,7 +419,7 @@ func is_focusable(node):
return true return true
if node.get_class() == "EditorInspectorSection": if node.get_class() == "EditorInspectorSection":
return true 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 false
return true return true