Use a separate object to encapsulate the node to make accessible and its related callbacks.

This commit is contained in:
Nolan Darilek 2018-05-28 16:48:02 +00:00
parent e72dfb8994
commit c0825b3dc1
2 changed files with 19 additions and 8 deletions

View File

@ -1,17 +1,11 @@
tool
extends EditorPlugin
func _focused():
print("Focus entered.")
func _gui_input():
print("GUI input.")
var Accessible = preload("accessible.gd")
func _augment_node(node):
if node is Control:
node.connect("focus_entered", self, "_focused")
node.connect("mouse_entered", self, "_focused")
node.connect("gui_input", self, "_gui_input")
Accessible.new(node)
func _enter_tree():
get_tree().connect("node_added", self, "_augment_node")

View File

@ -0,0 +1,17 @@
extends Object
var node
func _focused():
print("Focus entered.")
func _gui_input():
print("GUI input.")
func _init(node):
node.print_tree_pretty()
self.node = node
self.node.connect("focus_entered", self, "_focused")
self.node.connect("mouse_entered", self, "_focused")
self.node.connect("gui_input", self, "_gui_input")
self.node.connect("tree_exiting", self, "free")