From 9cf47e58f56ca29f7f0c3f857656bd76b52249d2 Mon Sep 17 00:00:00 2001 From: Thiago Seus Date: Sat, 5 Sep 2020 14:40:44 -0300 Subject: [PATCH] Fix texture buttons and some tool buttons not reading properly. --- Accessible.gd | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/Accessible.gd b/Accessible.gd index dc848d4..68c01f7 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -115,20 +115,43 @@ func _button_focused(): elif node.hint_tooltip: spoke_hint_tooltip = true tokens.append(node.hint_tooltip) + else: + tokens.append(get_graphical_button_text(node.icon)) tokens.append("button") if node.disabled: tokens.append("disabled") TTS.speak(tokens.join(": "), false) +func try_to_get_text_in_theme(theme, texture): + if theme == null: + return "" + + for type in theme.get_type_list(""): + for icon in theme.get_icon_list(type): + var icon_texture = theme.get_icon(icon, type) + if icon_texture == texture: + return icon + + return "" + + +func get_graphical_button_text(texture): + var default_theme_copy = Theme.new() + default_theme_copy.copy_default_theme() + var current = node + while current != null: + var text = try_to_get_text_in_theme(current.theme, texture) + if text != "": + return text + current = current.get_parent_control() + return try_to_get_text_in_theme(default_theme_copy, texture) + func texturebutton_focused(): - var texture = node.texture_normal - print_debug(texture.resource_name) - print_debug(texture.resource_path) - var rid = texture.get_rid() - print_debug(rid) - print_debug(rid.get_id()) - TTS.speak("button", false) + var tokens = PoolStringArray([]) + tokens.append(get_graphical_button_text(node.texture_normal)) + tokens.append("texture button") + TTS.speak(tokens.join(": ")) func item_list_item_focused(idx):