mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-24 21:05:57 +00:00
Begin adding support to enable/disable screen reader.
This commit is contained in:
parent
fa9e10b1ea
commit
fb56a4e37d
|
@ -11,6 +11,8 @@ signal swipe_down
|
|||
|
||||
var Accessible = preload("Accessible.gd")
|
||||
|
||||
export var enabled = true setget _set_enabled, _get_enabled
|
||||
|
||||
export var min_swipe_distance = 5
|
||||
|
||||
export var tap_execute_interval = 125
|
||||
|
@ -19,6 +21,16 @@ export var explore_by_touch_interval = 200
|
|||
|
||||
var focus_restore_timer
|
||||
|
||||
func _set_enabled(v):
|
||||
if enabled:
|
||||
augment_tree(get_tree().root)
|
||||
else:
|
||||
pass
|
||||
enabled = v
|
||||
|
||||
func _get_enabled():
|
||||
return enabled
|
||||
|
||||
func focused(node):
|
||||
focus_restore_timer = null
|
||||
|
||||
|
@ -29,6 +41,8 @@ func unfocused(node):
|
|||
focus_restore_timer = get_tree().create_timer(0.2)
|
||||
|
||||
func augment_node(node):
|
||||
if not enabled:
|
||||
return
|
||||
if node is Control:
|
||||
Accessible.new(node)
|
||||
if not node.is_connected("focus_entered", self, "focused"):
|
||||
|
@ -41,6 +55,8 @@ func augment_node(node):
|
|||
node.connect("mouse_exited", self, "unfocused", [node])
|
||||
|
||||
func augment_tree(node):
|
||||
if not enabled:
|
||||
return
|
||||
if node is Accessible:
|
||||
return
|
||||
augment_node(node)
|
||||
|
@ -77,6 +93,7 @@ func set_initial_scene_focus(scene):
|
|||
focus.grab_focus()
|
||||
|
||||
func _enter_tree():
|
||||
if enabled:
|
||||
augment_tree(get_tree().root)
|
||||
get_tree().connect("node_added", self, "augment_node")
|
||||
connect("swipe_right", self, "swipe_right")
|
||||
|
@ -139,6 +156,8 @@ var explore_by_touch = false
|
|||
var tap_count = 0
|
||||
|
||||
func _input(event):
|
||||
if not enabled:
|
||||
return
|
||||
if event is InputEventScreenTouch:
|
||||
get_tree().set_input_as_handled()
|
||||
if touch_index and event.index != touch_index:
|
||||
|
@ -178,6 +197,8 @@ func _input(event):
|
|||
get_tree().set_input_as_handled()
|
||||
|
||||
func _process(delta):
|
||||
if not enabled:
|
||||
return
|
||||
if touch_stop_time and OS.get_ticks_msec() - touch_stop_time >= tap_execute_interval and tap_count != 0:
|
||||
touch_stop_time = null
|
||||
if tap_count == 2:
|
||||
|
|
Loading…
Reference in New Issue
Block a user