Set an initial focus when the 3D screen appears.

This commit is contained in:
Nolan Darilek 2018-05-28 19:22:09 +00:00
parent 9298549c0d
commit 5d359dba8e
2 changed files with 16 additions and 0 deletions

View File

@ -7,8 +7,23 @@ func _augment_node(node):
if node is Control:
Accessible.new(node)
func _set_initial_screen_focus(screen):
var focus
var root = self
while root.get_parent() != null:
root = root.get_parent()
if screen == "3D":
focus = root.find_node("LineEdit", true, false)
print("Focus ",focus)
focus.grab_focus()
func _set_initial_scene_focus(scene):
print("Set focus in scene")
func _enter_tree():
get_tree().connect("node_added", self, "_augment_node")
connect("scene_changed", self, "_set_initial_scene_focus")
connect("main_screen_changed", self, "_set_initial_screen_focus")
func _exit_tree():
# Clean-up of the plugin goes here

View File

@ -9,6 +9,7 @@ func _gui_input():
print("GUI input.")
func _init(node):
print(node.get_path())
self.node = node
self.node.connect("focus_entered", self, "_focused")
self.node.connect("mouse_entered", self, "_focused")