mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-25 05:15:57 +00:00
Begin moving more functionality from ScreenReader
/Accessible
into the editor plugin.
This commit is contained in:
parent
76d1926385
commit
ccc79c93f6
21
Plugin.gd
21
Plugin.gd
|
@ -6,6 +6,21 @@ var ScreenReader = preload("ScreenReader.gd")
|
|||
var screen_reader
|
||||
|
||||
|
||||
func set_initial_screen_focus(screen):
|
||||
if not screen_reader.enabled:
|
||||
return
|
||||
TTS.speak("%s: screen" % screen, false)
|
||||
var control = screen_reader.find_focusable_control(get_tree().root)
|
||||
if control.get_focus_owner() != null:
|
||||
return
|
||||
screen_reader.augment_tree(get_tree().root)
|
||||
var focus = screen_reader.find_focusable_control(get_tree().root)
|
||||
if not focus:
|
||||
return
|
||||
focus.grab_click_focus()
|
||||
focus.grab_focus()
|
||||
|
||||
|
||||
func _enter_tree():
|
||||
var editor_accessibility_enabled = true
|
||||
var rate = 50
|
||||
|
@ -22,7 +37,7 @@ func _enter_tree():
|
|||
screen_reader = ScreenReader.new()
|
||||
screen_reader.enable_focus_mode = true
|
||||
get_tree().root.call_deferred("add_child", screen_reader)
|
||||
call_deferred("connect", "main_screen_changed", screen_reader, "set_initial_screen_focus")
|
||||
call_deferred("connect", "main_screen_changed", self, "_set_initial_screen_focus")
|
||||
add_custom_type("ScreenReader", "Node", preload("ScreenReader.gd"), null)
|
||||
|
||||
|
||||
|
@ -36,7 +51,7 @@ var _focus_loss_interval = 0
|
|||
func _process(delta):
|
||||
if not screen_reader.enabled:
|
||||
return
|
||||
var focus = screen_reader._find_focusable_control(get_tree().root)
|
||||
var focus = screen_reader.find_focusable_control(get_tree().root)
|
||||
focus = focus.get_focus_owner()
|
||||
if focus:
|
||||
_focus_loss_interval = 0
|
||||
|
@ -44,6 +59,6 @@ func _process(delta):
|
|||
_focus_loss_interval += delta
|
||||
if _focus_loss_interval >= 0.2:
|
||||
_focus_loss_interval = 0
|
||||
focus = screen_reader._find_focusable_control(get_tree().root)
|
||||
focus = screen_reader.find_focusable_control(get_tree().root)
|
||||
focus.grab_focus()
|
||||
focus.grab_click_focus()
|
||||
|
|
|
@ -52,20 +52,7 @@ func augment_tree(node):
|
|||
augment_tree(child)
|
||||
|
||||
|
||||
func set_initial_screen_focus(screen):
|
||||
TTS.speak("%s: screen" % screen, false)
|
||||
var control = _find_focusable_control(get_tree().root)
|
||||
if control.get_focus_owner() != null:
|
||||
return
|
||||
self.augment_tree(get_tree().root)
|
||||
var focus = _find_focusable_control(get_tree().root)
|
||||
if not focus:
|
||||
return
|
||||
focus.grab_click_focus()
|
||||
focus.grab_focus()
|
||||
|
||||
|
||||
func _find_focusable_control(node):
|
||||
func find_focusable_control(node):
|
||||
if (
|
||||
node is Control
|
||||
and node.is_visible_in_tree()
|
||||
|
@ -73,7 +60,7 @@ func _find_focusable_control(node):
|
|||
):
|
||||
return node
|
||||
for child in node.get_children():
|
||||
var result = _find_focusable_control(child)
|
||||
var result = find_focusable_control(child)
|
||||
if result:
|
||||
return result
|
||||
return null
|
||||
|
@ -150,7 +137,7 @@ func swipe_left():
|
|||
|
||||
|
||||
func swipe_up():
|
||||
var focus = _find_focusable_control(get_tree().root)
|
||||
var focus = find_focusable_control(get_tree().root)
|
||||
if focus:
|
||||
focus = focus.get_focus_owner()
|
||||
if focus:
|
||||
|
@ -159,7 +146,7 @@ func swipe_up():
|
|||
|
||||
|
||||
func swipe_down():
|
||||
var focus = _find_focusable_control(get_tree().root)
|
||||
var focus = find_focusable_control(get_tree().root)
|
||||
if focus:
|
||||
focus = focus.get_focus_owner()
|
||||
if focus:
|
||||
|
|
Loading…
Reference in New Issue
Block a user