mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-12-22 07:35:56 +00:00
Return to having Accessible
be a Node
under ScreenReader
, and having _exit_tree
free resources.
This eliminates the need to track and iterate through a separate array of `Accessible`s in `ScreenReader`. The previous performance issues are resolved by ensuring that any nodes processed aren't children of the `ScreenReader` node. I don't know of another way to avoid triggering signals on a child node than checking ancestry and failing fast.
This commit is contained in:
parent
24483e4453
commit
d9c740abd6
|
@ -499,7 +499,6 @@ func unfocused():
|
|||
if not node.get_focus_owner():
|
||||
node.get_tree().root.warp_mouse(node.rect_global_position)
|
||||
timer.unreference()
|
||||
timer = null
|
||||
|
||||
func click_focused():
|
||||
if node.has_focus():
|
||||
|
@ -626,4 +625,8 @@ func _init(node):
|
|||
node.connect("cell_selected", self, "tree_item_selected")
|
||||
else:
|
||||
node.connect("item_selected", self, "tree_item_selected")
|
||||
node.connect("tree_exiting", self, "free", [], Object.CONNECT_DEFERRED)
|
||||
node.connect("tree_exiting", self, "queue_free", [], Object.CONNECT_DEFERRED)
|
||||
|
||||
func _exit_tree():
|
||||
if timer != null:
|
||||
timer.unreference()
|
||||
|
|
|
@ -3,8 +3,6 @@ extends Node
|
|||
|
||||
var Accessible = preload("Accessible.gd")
|
||||
|
||||
var accessibles = []
|
||||
|
||||
var focus_restore_timer = Timer.new()
|
||||
|
||||
func focused(node):
|
||||
|
@ -26,7 +24,7 @@ func unfocused(node):
|
|||
func augment_node(node):
|
||||
if node is Control:
|
||||
var accessible = Accessible.new(node)
|
||||
accessibles.append(accessible)
|
||||
add_child(accessible)
|
||||
if not node.is_connected("focus_entered", self, "focused"):
|
||||
node.connect("focus_entered", self, "focused", [node])
|
||||
if not node.is_connected("mouse_entered", self, "click_focused"):
|
||||
|
@ -37,6 +35,8 @@ func augment_node(node):
|
|||
node.connect("mouse_exited", self, "unfocused", [node])
|
||||
|
||||
func augment_tree(node):
|
||||
if node is Accessible:
|
||||
return
|
||||
augment_node(node)
|
||||
for child in node.get_children():
|
||||
augment_tree(child)
|
||||
|
@ -75,10 +75,3 @@ func _enter_tree():
|
|||
focus_restore_timer.connect("timeout", self, "restore_focus")
|
||||
add_child(focus_restore_timer)
|
||||
get_tree().connect("node_added", self, "augment_tree")
|
||||
|
||||
func _exit_tree():
|
||||
for accessible in accessibles:
|
||||
if accessible.timer != null:
|
||||
accessible.timer.unreference()
|
||||
accessible.timer = null
|
||||
accessible.free()
|
||||
|
|
Loading…
Reference in New Issue
Block a user