From fdd5f1a5f6f68d86f340da7ff5b3b3a2df090fbb Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 10 Oct 2019 09:49:54 -0500 Subject: [PATCH] Assorted changes: * Try to improve list selection handling. * Use `get_class()` to check class membership for editor classes not included in exported games. --- Accessible.gd | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Accessible.gd b/Accessible.gd index 00da4ba..c22ac37 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -28,9 +28,9 @@ func guess_label(): var tokens = PoolStringArray([]) var to_check = node while to_check: - if to_check is EditorProperty and to_check.label: + if to_check.get_class() == "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(): + if (to_check.get_class() == "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: @@ -91,13 +91,21 @@ func item_list_item_focused(idx): func item_list_focused(): var count = node.get_item_count() - var selected = node.get_selected_items()[0] + var selected = node.get_selected_items() + print(selected) + if len(selected) == 0: + if node.get_item_count() == 0: + return TTS.speak("list, 0 items", false) + selected = 0 + node.select(selected) + node.emit_signal("item_list_item_selected", selected) + else: + selected = selected[0] position_in_children = selected - TTS.speak("list, %s %s" % [count, TTS.singular_or_plural(count, "item", "items")], false) item_list_item_focused(selected) func item_list_item_selected(index): - TTS.speak("Selected", true) + item_list_item_focused(index) func item_list_multi_selected(index, selected): TTS.speak("Multiselect", false) @@ -131,6 +139,7 @@ func item_list_input(event): position_in_children = 0 node.unselect_all() node.select(position_in_children) + node.emit_signal("item_list_item_selected", position_in_children) item_list_item_focused(position_in_children) func label_focused():