From 1f5a6a878ffe210672e84ca9841064ba75cf0db2 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 9 Sep 2019 08:35:05 -0500 Subject: [PATCH] Add better `CheckBox` handling, and comment out notification print debugging. --- addons/accessibility/accessibility.gd | 2 +- addons/accessibility/accessible.gd | 28 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/addons/accessibility/accessibility.gd b/addons/accessibility/accessibility.gd index 45200c6..2b619c0 100644 --- a/addons/accessibility/accessibility.gd +++ b/addons/accessibility/accessibility.gd @@ -56,6 +56,6 @@ func _exit_tree(): pass func _notification(what): - print("Notified: %s" % what) + # print("Notified: %s" % what) if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST: print("User requested the project to quit") diff --git a/addons/accessibility/accessible.gd b/addons/accessibility/accessible.gd index a43c5c4..fc70693 100644 --- a/addons/accessibility/accessible.gd +++ b/addons/accessibility/accessible.gd @@ -43,6 +43,28 @@ func accept_dialog_focus(): if dialog_close_timer.get_parent() == null: node.add_child(dialog_close_timer) +func checkbox_focus(): + var text = "" + if node.text: + text = node.text + var state + if node.pressed: + state = "checked" + else: + state = "unchecked" + if text: + text += ": " + state + else: + text = state + text += " checkbox" + tts.speak(text, false) + +func checkbox_toggled(checked): + if checked: + tts.speak("checked", true) + else: + tts.speak("unchecked", true) + func button_focus(): var text if node.text: @@ -295,6 +317,8 @@ func focused(): menu_button_focus() elif node is AcceptDialog: accept_dialog_focus() + elif node is CheckBox: + checkbox_focus() elif node is Button: button_focus() elif node.get_class() == "EditorInspectorSection": @@ -392,7 +416,9 @@ func _init(tts, node): node.connect("focus_exited", self, "unfocused") node.connect("mouse_exited", self, "unfocused") node.connect("gui_input", self, "gui_input") - if node is ItemList: + if node is CheckBox: + node.connect("toggled", self, "checkbox_toggled") + elif node is ItemList: node.connect("item_selected", self, "item_list_item_selected") node.connect("multi_selected", self, "item_list_multi_selected") node.connect("nothing_selected", self, "item_list_nothing_selected")