From fbbbb1e06ed0f2f808247ab8d88d6da6c9c12dd9 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Mon, 30 Dec 2019 08:25:57 -0600 Subject: [PATCH] Revert "Apparently, `focused` is triggered on `mouse_enter` as well, so this code isn't needed." Necessary for next commit, which selectively ignores mouse events and needs this code for explore-by-touch. This reverts commit dc6186c58370e34b6ff67131c90931274ee7598b. --- Accessible.gd | 9 +++++++++ ScreenReader.gd | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/Accessible.gd b/Accessible.gd index 9d2a6f2..c7d5b54 100644 --- a/Accessible.gd +++ b/Accessible.gd @@ -502,6 +502,13 @@ func unfocused(): position_in_children = 0 timer = node.get_tree().create_timer(1) +func click_focused(): + if node.has_focus(): + return + if node.focus_mode == Control.FOCUS_ALL: + print_debug("Grabbing focus: %s" % node) + node.grab_focus() + func gui_input(event): if event is InputEventKey and Input.is_action_just_pressed("ui_accept") and event.control and event.alt: TTS.speak("click", false) @@ -592,7 +599,9 @@ func _init(node): if is_focusable(node): node.set_focus_mode(Control.FOCUS_ALL) node.connect("focus_entered", self, "focused") + node.connect("mouse_entered", self, "click_focused") node.connect("focus_exited", self, "unfocused") + node.connect("mouse_exited", self, "unfocused") node.connect("gui_input", self, "gui_input") if node is CheckBox: node.connect("toggled", self, "checkbox_toggled") diff --git a/ScreenReader.gd b/ScreenReader.gd index 594d2ac..c4208a1 100644 --- a/ScreenReader.gd +++ b/ScreenReader.gd @@ -24,6 +24,9 @@ var focus_restore_timer func focused(node): focus_restore_timer = null +func click_focused(node): + pass + func unfocused(node): focus_restore_timer = get_tree().create_timer(0.2) @@ -33,8 +36,12 @@ func augment_node(node): accessibles.append(accessible) if not node.is_connected("focus_entered", self, "focused"): node.connect("focus_entered", self, "focused", [node]) + if not node.is_connected("mouse_entered", self, "click_focused"): + node.connect("mouse_entered", self, "click_focused", [node]) if not node.is_connected("focus_exited", self, "unfocused"): node.connect("focus_exited", self, "unfocused", [node]) + if not node.is_connected("mouse_exited", self, "unfocused"): + node.connect("mouse_exited", self, "unfocused", [node]) func augment_tree(node): if node is Accessible: