mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 03:45: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
|
tool
|
||||||
extends EditorPlugin
|
extends EditorPlugin
|
||||||
|
|
||||||
func _focused():
|
var Accessible = preload("accessible.gd")
|
||||||
print("Focus entered.")
|
|
||||||
|
|
||||||
func _gui_input():
|
|
||||||
print("GUI input.")
|
|
||||||
|
|
||||||
func _augment_node(node):
|
func _augment_node(node):
|
||||||
if node is Control:
|
if node is Control:
|
||||||
node.connect("focus_entered", self, "_focused")
|
Accessible.new(node)
|
||||||
node.connect("mouse_entered", self, "_focused")
|
|
||||||
node.connect("gui_input", self, "_gui_input")
|
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
get_tree().connect("node_added", self, "_augment_node")
|
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