mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 03:45:56 +00:00
Redirect "ui_accept" input for specific Tree
edge cases.
Trees appear to eat "ui_accept" before `gui_input` receives it. This makes certain use cases--triggering buttons in cells--impossible via the keyboard. Here, `ScreenReader` attempts to intercept recent presses of "ui_accept" and, if a button in a cell should receive focus, redirects the `InputEvent` to the custom handler for `Tree`. Unfortunately, this loses the ability to click buttons in cells in the editor's node tree for some reason. It restores, or maybe gets working in the first place, clicking on the _Remove_ button in the input mapping screen. Not sure how to restore the former functionality--these trees are complex and not well-documented.
This commit is contained in:
parent
d522da8fc0
commit
6beeaa01bd
|
@ -351,6 +351,8 @@ func text_edit_input(event):
|
||||||
|
|
||||||
var _last_tree_item_tokens
|
var _last_tree_item_tokens
|
||||||
|
|
||||||
|
var button_index
|
||||||
|
|
||||||
|
|
||||||
func _tree_item_render():
|
func _tree_item_render():
|
||||||
if not node.has_focus():
|
if not node.has_focus():
|
||||||
|
@ -372,7 +374,15 @@ func _tree_item_render():
|
||||||
tokens.append("expanded")
|
tokens.append("expanded")
|
||||||
var button_count = cell.get_button_count(i)
|
var button_count = cell.get_button_count(i)
|
||||||
if button_count != 0:
|
if button_count != 0:
|
||||||
|
var column
|
||||||
|
for j in range(node.columns):
|
||||||
|
if cell.is_selected(j):
|
||||||
|
column = j
|
||||||
|
break
|
||||||
|
if column == i:
|
||||||
button_index = 0
|
button_index = 0
|
||||||
|
else:
|
||||||
|
button_index = null
|
||||||
tokens.append(
|
tokens.append(
|
||||||
(
|
(
|
||||||
str(button_count)
|
str(button_count)
|
||||||
|
@ -380,6 +390,7 @@ func _tree_item_render():
|
||||||
+ TTS.singular_or_plural(button_count, "button", "buttons")
|
+ TTS.singular_or_plural(button_count, "button", "buttons")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
if button_index != null:
|
||||||
var button_tooltip = cell.get_button_tooltip(i, button_index)
|
var button_tooltip = cell.get_button_tooltip(i, button_index)
|
||||||
if button_tooltip:
|
if button_tooltip:
|
||||||
tokens.append(button_tooltip)
|
tokens.append(button_tooltip)
|
||||||
|
@ -394,8 +405,6 @@ func _tree_item_render():
|
||||||
|
|
||||||
var prev_selected_cell
|
var prev_selected_cell
|
||||||
|
|
||||||
var button_index
|
|
||||||
|
|
||||||
|
|
||||||
func _tree_item_or_cell_selected():
|
func _tree_item_or_cell_selected():
|
||||||
button_index = null
|
button_index = null
|
||||||
|
@ -430,8 +439,8 @@ func _tree_input(event):
|
||||||
node.rect_global_position.y + area.position.y + area.size.y / 2
|
node.rect_global_position.y + area.position.y + area.size.y / 2
|
||||||
)
|
)
|
||||||
node.get_tree().root.warp_mouse(position)
|
node.get_tree().root.warp_mouse(position)
|
||||||
if item and column != null and button_index != null:
|
if item and column != null and item.get_button_count(column):
|
||||||
if event.is_action_pressed("ui_accept"):
|
if Input.is_action_just_pressed("ui_accept"):
|
||||||
node.accept_event()
|
node.accept_event()
|
||||||
return node.emit_signal("button_pressed", item, column, button_index + 1)
|
return node.emit_signal("button_pressed", item, column, button_index + 1)
|
||||||
var new_button_index = button_index
|
var new_button_index = button_index
|
||||||
|
|
|
@ -173,6 +173,18 @@ var in_focus_mode_handler = false
|
||||||
func _input(event):
|
func _input(event):
|
||||||
if not enabled:
|
if not enabled:
|
||||||
return
|
return
|
||||||
|
var focus = find_focusable_control(get_tree().root)
|
||||||
|
if focus:
|
||||||
|
focus = focus.get_focus_owner()
|
||||||
|
if focus is Tree and Input.is_action_just_pressed("ui_accept"):
|
||||||
|
var accessible
|
||||||
|
for n in focus.get_children():
|
||||||
|
if n is Accessible:
|
||||||
|
accessible = n
|
||||||
|
break
|
||||||
|
if accessible and accessible.button_index != null:
|
||||||
|
accessible._tree_input(event)
|
||||||
|
get_tree().set_input_as_handled()
|
||||||
if enable_focus_mode:
|
if enable_focus_mode:
|
||||||
if (
|
if (
|
||||||
event is InputEventKey
|
event is InputEventKey
|
||||||
|
|
Loading…
Reference in New Issue
Block a user