From 24d3ea596b70d51c9c49ac89263cf2f7e17d4964 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Wed, 25 Sep 2019 17:18:01 -0500 Subject: [PATCH] Slightly better `ItemList` handling, though for some reason I can't make it work in file selections. --- Accessible.gd | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/Accessible.gd b/Accessible.gd index b2568fe..0a2743c 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -73,11 +73,23 @@ func button_focus(): func texturebutton_focus(): tts.speak("button", false) +func item_list_item_focused(idx): + var tokens = PoolStringArray([]) + var text = node.get_item_text(idx) + if text: + tokens.append(text) + text = node.get_item_tooltip(idx) + if text: + tokens.append(text) + tokens.append("%s of %s" % [idx + 1, node.get_item_count()]) + tts.speak(tokens.join(": ")) + func item_list_focus(): var count = node.get_item_count() - var selected = node.get_selected_items() + var selected = node.get_selected_items()[0] + position_in_children = selected tts.speak("list, %s %s" % [count, tts.singular_or_plural(count, "item", "items")], false) - tts.speak(selected, false) + item_list_item_focused(selected) func item_list_item_selected(index): tts.speak("Selected", true) @@ -107,8 +119,9 @@ func item_list_input(event): node.accept_event() position_in_children = node.get_item_count()-1 if old_pos != position_in_children: - var text = node.get_item_text(position_in_children) - tts.speak("%s: %s of %s" % [text, position_in_children+1, node.get_item_count()], false) + node.unselect_all() + node.select(position_in_children) + item_list_item_focused(position_in_children) func label_focus(): var text = node.text