mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-12-22 07:35:56 +00:00
Use a separate object to encapsulate the node to make accessible and its related callbacks.
This commit is contained in:
parent
e72dfb8994
commit
c0825b3dc1
|
@ -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")
|
||||
|
|
17
addons/accessibility/accessible.gd
Normal file
17
addons/accessibility/accessible.gd
Normal 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")
|
Loading…
Reference in New Issue
Block a user