2018-05-26 11:34:15 +00:00
|
|
|
tool
|
|
|
|
extends EditorPlugin
|
|
|
|
|
2018-05-28 16:48:02 +00:00
|
|
|
var Accessible = preload("accessible.gd")
|
2018-05-26 14:47:18 +00:00
|
|
|
|
2018-05-28 21:45:13 +00:00
|
|
|
func augment_node(node):
|
2018-05-26 14:47:18 +00:00
|
|
|
if node is Control:
|
2018-05-28 16:48:02 +00:00
|
|
|
Accessible.new(node)
|
2018-05-26 14:47:18 +00:00
|
|
|
|
2018-06-07 21:28:33 +00:00
|
|
|
func augment_tree(node):
|
|
|
|
augment_node(node)
|
|
|
|
for child in node.get_children():
|
|
|
|
augment_node(child)
|
|
|
|
|
2018-05-28 21:45:13 +00:00
|
|
|
func set_initial_screen_focus(screen):
|
2018-05-28 21:09:29 +00:00
|
|
|
print("Screen ",screen)
|
2018-05-28 19:22:09 +00:00
|
|
|
var focus
|
2018-06-07 21:13:55 +00:00
|
|
|
var root = get_tree().root
|
2018-06-07 21:28:33 +00:00
|
|
|
augment_tree(root)
|
2018-05-28 19:22:09 +00:00
|
|
|
if screen == "3D":
|
2018-05-28 21:09:29 +00:00
|
|
|
focus = root.find_node("ToolButton", true, false)
|
2018-06-07 21:31:59 +00:00
|
|
|
if focus is Control:
|
|
|
|
print("Focus ",focus)
|
|
|
|
focus.grab_click_focus()
|
|
|
|
focus.grab_focus()
|
2018-05-28 19:22:09 +00:00
|
|
|
|
2018-05-28 21:45:13 +00:00
|
|
|
func set_initial_scene_focus(scene):
|
2018-05-28 19:22:09 +00:00
|
|
|
print("Set focus in scene")
|
|
|
|
|
2018-05-26 11:34:15 +00:00
|
|
|
func _enter_tree():
|
2018-05-28 21:45:13 +00:00
|
|
|
get_tree().connect("node_added", self, "augment_node")
|
|
|
|
connect("scene_changed", self, "set_initial_scene_focus")
|
|
|
|
connect("main_screen_changed", self, "set_initial_screen_focus")
|
2018-05-26 11:34:15 +00:00
|
|
|
|
|
|
|
func _exit_tree():
|
|
|
|
# Clean-up of the plugin goes here
|
|
|
|
pass
|