mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 11:55:56 +00:00
Move all accessibility code into Accessible class. Also, add tree-augmenting function to make an entire tree accessible.
This commit is contained in:
parent
319c1297c4
commit
2f1ad85f1d
|
@ -5,13 +5,18 @@ 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 augment_tree(node):
|
||||||
|
augment_node(node)
|
||||||
|
for child in node.get_children():
|
||||||
|
augment_node(child)
|
||||||
|
|
||||||
func set_initial_screen_focus(screen):
|
func set_initial_screen_focus(screen):
|
||||||
print("Screen ",screen)
|
print("Screen ",screen)
|
||||||
var focus
|
var focus
|
||||||
var root = get_tree().root
|
var root = get_tree().root
|
||||||
|
augment_tree(root)
|
||||||
if screen == "3D":
|
if screen == "3D":
|
||||||
focus = root.find_node("ToolButton", true, false)
|
focus = root.find_node("ToolButton", true, false)
|
||||||
print("Focus ",focus)
|
print("Focus ",focus)
|
||||||
|
|
|
@ -3,10 +3,10 @@ extends Object
|
||||||
var node
|
var node
|
||||||
|
|
||||||
func focused():
|
func focused():
|
||||||
print("Focus entered.")
|
print("Focus entered.", self.node)
|
||||||
|
|
||||||
func unfocused():
|
func unfocused():
|
||||||
print("Unfocused")
|
print("Unfocused", self.node)
|
||||||
|
|
||||||
func gui_input():
|
func gui_input():
|
||||||
print("GUI input.")
|
print("GUI input.")
|
||||||
|
@ -15,8 +15,9 @@ func _init(node):
|
||||||
if node.is_in_group("accessible"):
|
if node.is_in_group("accessible"):
|
||||||
return
|
return
|
||||||
node.add_to_group("accessible")
|
node.add_to_group("accessible")
|
||||||
# print(node.get_path())
|
print(node.get_path())
|
||||||
self.node = node
|
self.node = node
|
||||||
|
self.node.set_focus_mode(Control.FOCUS_ALL)
|
||||||
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("focus_exited", self, "unfocused")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user