From eeb8a3a171ab46a1e632187503e1d5256a4b22bb Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Tue, 24 Sep 2019 15:13:15 -0500 Subject: [PATCH] Check for the presence of added methods so the plugin will partially work on unpatched engines. --- Accessible.gd | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Accessible.gd b/Accessible.gd index 54d9db4..60e2c3e 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -33,11 +33,17 @@ func click(item := node, button_index = BUTTON_LEFT): node.get_tree().input_event(click) func guess_label(): - var parent = node.get_parent() - while parent: - if parent is EditorProperty and parent.label: - return parent.label - parent = parent.get_parent() + var tokens = PoolStringArray([]) + var to_check = node + while to_check: + if to_check is EditorProperty and to_check.label: + tokens.append(to_check.label) + if (to_check is EditorProperty or to_check.get_class() == "EditorInspectorCategory") and to_check.get_tooltip_text(): + tokens.append(to_check.get_tooltip_text()) + var label = tokens.join(": ") + if label: + return label + to_check = to_check.get_parent() func close_key_event_dialog(): node.get_ok().emit_signal("pressed") @@ -252,12 +258,13 @@ func tree_item_selected(): if button_count != 0: button_index = 0 tokens.append(str(button_count) + " " + singular_or_plural(button_count, "button", "buttons")) - var button_tooltip = cell.get_button_tooltip(i, button_index) - if button_tooltip: - tokens.append(button_tooltip) - tokens.append("button") - if button_count > 1: - tokens.append("Use Home and End to switch focus.") + if cell.has_method("get_button_tooltip"): + var button_tooltip = cell.get_button_tooltip(i, button_index) + if button_tooltip: + tokens.append(button_tooltip) + tokens.append("button") + if button_count > 1: + tokens.append("Use Home and End to switch focus.") tts.speak(tokens.join(": "), true) func tree_item_multi_select(item, column, selected): @@ -297,7 +304,7 @@ func tree_input(event): new_button_index -= 1 if new_button_index < 0: new_button_index = item.get_button_count(column) - 1 - if new_button_index != button_index: + if new_button_index != button_index and item.has_method("get_button_tooltip"): button_index = new_button_index var tokens = PoolStringArray([]) var tooltip = item.get_button_tooltip(column, button_index)