From 75844f66d9339ac7d9c4202d08ee34e1338aeac3 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 2 Sep 2019 09:55:51 -0500 Subject: [PATCH] Access to `TabContainer`. --- addons/accessibility/accessible.gd | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/addons/accessibility/accessible.gd b/addons/accessibility/accessible.gd index c39607e..e8ed9fc 100644 --- a/addons/accessibility/accessible.gd +++ b/addons/accessibility/accessible.gd @@ -136,6 +136,27 @@ func render_tree_item(): var result = item.get_text(0) return result +func focus_tab_container(): + var text = node.get_tab_title(node.current_tab) + text += ": tab: " + str(node.current_tab + 1) + " of " + str(node.get_tab_count()) + tts.speak(text, false) + +func input_tab_container(event): + tts.stop() + var new_tab = node.current_tab + if event.echo or not event.pressed: + return + if event.scancode == KEY_RIGHT: + new_tab += 1 + elif event.scancode == KEY_LEFT: + new_tab -= 1 + if new_tab < 0: + new_tab = node.get_tab_count() - 1 + elif new_tab >= node.get_tab_count(): + new_tab = 0 + node.current_tab = new_tab + focus_tab_container() + func focus_tree(): if node.get_selected(): tts.speak(render_tree_item(), true) @@ -164,6 +185,8 @@ func focused(): focus_line_edit() elif node is PopupMenu: focus_popup_menu() + elif node is TabContainer: + focus_tab_container() elif node is Tree: focus_tree() else: @@ -175,6 +198,8 @@ func unfocused(): position_in_children = 0 func gui_input(event): + if node is TabContainer: + return input_tab_container(event) if node is ItemList: return input_item_list(event) elif node is LineEdit: @@ -188,6 +213,8 @@ func _init(tts, node): self.node = node if not node is Container and not node is Panel and not node is Separator and not node is ScrollBar and not node is Popup and node.get_class() != "Control": node.set_focus_mode(Control.FOCUS_ALL) + elif node is TabContainer: + node.set_focus_mode(Control.FOCUS_ALL) node.connect("focus_entered", self, "focused") node.connect("mouse_entered", self, "focused") node.connect("focus_exited", self, "unfocused")