mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 03:45:56 +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")
|
var Accessible = preload("Accessible.gd")
|
||||||
|
|
||||||
|
export var enabled = true setget _set_enabled, _get_enabled
|
||||||
|
|
||||||
export var min_swipe_distance = 5
|
export var min_swipe_distance = 5
|
||||||
|
|
||||||
export var tap_execute_interval = 125
|
export var tap_execute_interval = 125
|
||||||
|
@ -19,6 +21,16 @@ export var explore_by_touch_interval = 200
|
||||||
|
|
||||||
var focus_restore_timer
|
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):
|
func focused(node):
|
||||||
focus_restore_timer = null
|
focus_restore_timer = null
|
||||||
|
|
||||||
|
@ -29,6 +41,8 @@ func unfocused(node):
|
||||||
focus_restore_timer = get_tree().create_timer(0.2)
|
focus_restore_timer = get_tree().create_timer(0.2)
|
||||||
|
|
||||||
func augment_node(node):
|
func augment_node(node):
|
||||||
|
if not enabled:
|
||||||
|
return
|
||||||
if node is Control:
|
if node is Control:
|
||||||
Accessible.new(node)
|
Accessible.new(node)
|
||||||
if not node.is_connected("focus_entered", self, "focused"):
|
if not node.is_connected("focus_entered", self, "focused"):
|
||||||
|
@ -41,6 +55,8 @@ func augment_node(node):
|
||||||
node.connect("mouse_exited", self, "unfocused", [node])
|
node.connect("mouse_exited", self, "unfocused", [node])
|
||||||
|
|
||||||
func augment_tree(node):
|
func augment_tree(node):
|
||||||
|
if not enabled:
|
||||||
|
return
|
||||||
if node is Accessible:
|
if node is Accessible:
|
||||||
return
|
return
|
||||||
augment_node(node)
|
augment_node(node)
|
||||||
|
@ -77,6 +93,7 @@ func set_initial_scene_focus(scene):
|
||||||
focus.grab_focus()
|
focus.grab_focus()
|
||||||
|
|
||||||
func _enter_tree():
|
func _enter_tree():
|
||||||
|
if enabled:
|
||||||
augment_tree(get_tree().root)
|
augment_tree(get_tree().root)
|
||||||
get_tree().connect("node_added", self, "augment_node")
|
get_tree().connect("node_added", self, "augment_node")
|
||||||
connect("swipe_right", self, "swipe_right")
|
connect("swipe_right", self, "swipe_right")
|
||||||
|
@ -139,6 +156,8 @@ var explore_by_touch = false
|
||||||
var tap_count = 0
|
var tap_count = 0
|
||||||
|
|
||||||
func _input(event):
|
func _input(event):
|
||||||
|
if not enabled:
|
||||||
|
return
|
||||||
if event is InputEventScreenTouch:
|
if event is InputEventScreenTouch:
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
if touch_index and event.index != touch_index:
|
if touch_index and event.index != touch_index:
|
||||||
|
@ -178,6 +197,8 @@ func _input(event):
|
||||||
get_tree().set_input_as_handled()
|
get_tree().set_input_as_handled()
|
||||||
|
|
||||||
func _process(delta):
|
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:
|
if touch_stop_time and OS.get_ticks_msec() - touch_stop_time >= tap_execute_interval and tap_count != 0:
|
||||||
touch_stop_time = null
|
touch_stop_time = null
|
||||||
if tap_count == 2:
|
if tap_count == 2:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user