Try everything I can think of to get focus working. Grab click focus, make every single control focusable every way possible, track focus_exited for more insight. Nothing works.

This commit is contained in:
Nolan Darilek 2018-05-28 21:09:29 +00:00
parent 5d359dba8e
commit 035a0699e1
2 changed files with 10 additions and 2 deletions

View File

@ -5,16 +5,19 @@ var Accessible = preload("accessible.gd")
func _augment_node(node): func _augment_node(node):
if node is Control: if node is Control:
node.set_focus_mode(Control.FOCUS_ALL)
Accessible.new(node) Accessible.new(node)
func _set_initial_screen_focus(screen): func _set_initial_screen_focus(screen):
print("Screen ",screen)
var focus var focus
var root = self var root = self
while root.get_parent() != null: while root.get_parent() != null:
root = root.get_parent() root = root.get_parent()
if screen == "3D": if screen == "3D":
focus = root.find_node("LineEdit", true, false) focus = root.find_node("ToolButton", true, false)
print("Focus ",focus) print("Focus ",focus)
focus.grab_click_focus()
focus.grab_focus() focus.grab_focus()
func _set_initial_scene_focus(scene): func _set_initial_scene_focus(scene):

View File

@ -5,13 +5,18 @@ var node
func _focused(): func _focused():
print("Focus entered.") print("Focus entered.")
func _unfocused():
print("Unfocused")
func _gui_input(): func _gui_input():
print("GUI input.") print("GUI input.")
func _init(node): func _init(node):
print(node.get_path()) # print(node.get_path())
self.node = node self.node = node
self.node.connect("focus_entered", self, "_focused") self.node.connect("focus_entered", self, "_focused")
self.node.connect("mouse_entered", self, "_focused") self.node.connect("mouse_entered", self, "_focused")
self.node.connect("focus_exited", self, "_unfocused")
self.node.connect("mouse_exited", self, "_unfocused")
self.node.connect("gui_input", self, "_gui_input") self.node.connect("gui_input", self, "_gui_input")
self.node.connect("tree_exiting", self, "free") self.node.connect("tree_exiting", self, "free")