mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-12-22 07:35:56 +00:00
Initial focus is set, and focus changes are reported.
This commit is contained in:
parent
c81d3fc4a4
commit
df410e5802
|
@ -10,19 +10,25 @@ func augment_node(node):
|
|||
func augment_tree(node):
|
||||
augment_node(node)
|
||||
for child in node.get_children():
|
||||
augment_node(child)
|
||||
augment_tree(child)
|
||||
|
||||
func set_initial_screen_focus(screen):
|
||||
print("Screen ",screen)
|
||||
var focus
|
||||
var root = get_tree().root
|
||||
augment_tree(root)
|
||||
if screen == "3D":
|
||||
focus = root.find_node("ToolButton", true, false)
|
||||
if focus is Control:
|
||||
print("Focus ",focus)
|
||||
focus.grab_click_focus()
|
||||
focus.grab_focus()
|
||||
self.augment_tree(get_tree().root)
|
||||
var focus = find_focusable_control(get_tree().root)
|
||||
print("Focus ",focus, focus.is_in_group("accessible"))
|
||||
if not focus:
|
||||
return
|
||||
focus.grab_click_focus()
|
||||
focus.grab_focus()
|
||||
|
||||
func find_focusable_control(node):
|
||||
if node is Control and node.is_visible_in_tree() and (node.focus_mode == Control.FOCUS_CLICK or node.focus_mode == Control.FOCUS_ALL):
|
||||
return node
|
||||
for child in node.get_children():
|
||||
var result = find_focusable_control(child)
|
||||
if result:
|
||||
return result
|
||||
return null
|
||||
|
||||
func set_initial_scene_focus(scene):
|
||||
print("Set focus in scene")
|
||||
|
|
|
@ -6,18 +6,17 @@ func focused():
|
|||
print("Focus entered.", self.node)
|
||||
|
||||
func unfocused():
|
||||
print("Unfocused", self.node)
|
||||
pass
|
||||
|
||||
func gui_input():
|
||||
print("GUI input.")
|
||||
func gui_input(event):
|
||||
pass
|
||||
|
||||
func _init(node):
|
||||
if node.is_in_group("accessible"):
|
||||
return
|
||||
node.add_to_group("accessible")
|
||||
print(node.get_path())
|
||||
self.node = node
|
||||
self.node.set_focus_mode(Control.FOCUS_ALL)
|
||||
# self.node.set_focus_mode(Control.FOCUS_ALL)
|
||||
self.node.connect("focus_entered", self, "focused")
|
||||
self.node.connect("mouse_entered", self, "focused")
|
||||
self.node.connect("focus_exited", self, "unfocused")
|
||||
|
|
Loading…
Reference in New Issue
Block a user