Merge pull request #4 from thgcode/button-fix

Fix texture buttons and some tool buttons not reading properly.
This commit is contained in:
Nolan Darilek 2020-09-11 10:36:15 -05:00 committed by GitHub
commit 0a44f1397c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,20 +115,43 @@ func _button_focused():
elif node.hint_tooltip: elif node.hint_tooltip:
spoke_hint_tooltip = true spoke_hint_tooltip = true
tokens.append(node.hint_tooltip) tokens.append(node.hint_tooltip)
else:
tokens.append(get_graphical_button_text(node.icon))
tokens.append("button") tokens.append("button")
if node.disabled: if node.disabled:
tokens.append("disabled") tokens.append("disabled")
TTS.speak(tokens.join(": "), false) 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(): func texturebutton_focused():
var texture = node.texture_normal var tokens = PoolStringArray([])
print_debug(texture.resource_name) tokens.append(get_graphical_button_text(node.texture_normal))
print_debug(texture.resource_path) tokens.append("texture button")
var rid = texture.get_rid() TTS.speak(tokens.join(": "))
print_debug(rid)
print_debug(rid.get_id())
TTS.speak("button", false)
func item_list_item_focused(idx): func item_list_item_focused(idx):