mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 11:55:56 +00:00
Clean up code such that control names and their backing implementations are easier to associate.
This commit is contained in:
parent
aa93b0e294
commit
1cbc59aa6f
|
@ -14,7 +14,7 @@ func item_or_items(count):
|
||||||
else:
|
else:
|
||||||
return "items"
|
return "items"
|
||||||
|
|
||||||
func focus_button():
|
func button_focus():
|
||||||
var text
|
var text
|
||||||
if node.text:
|
if node.text:
|
||||||
text = node.text
|
text = node.text
|
||||||
|
@ -23,7 +23,7 @@ func focus_button():
|
||||||
else:
|
else:
|
||||||
tts.speak("button", false)
|
tts.speak("button", false)
|
||||||
|
|
||||||
func focus_item_list():
|
func item_list_focus():
|
||||||
var count = node.get_item_count()
|
var count = node.get_item_count()
|
||||||
var selected = node.get_selected_items()
|
var selected = node.get_selected_items()
|
||||||
tts.speak("list, %s %s" % [count, item_or_items(count)], false)
|
tts.speak("list, %s %s" % [count, item_or_items(count)], false)
|
||||||
|
@ -38,7 +38,7 @@ func item_list_multi_selected(index, selected):
|
||||||
func item_list_nothing_selected():
|
func item_list_nothing_selected():
|
||||||
tts.speak("Nothing selected", false)
|
tts.speak("Nothing selected", false)
|
||||||
|
|
||||||
func input_item_list(event):
|
func item_list_input(event):
|
||||||
if event.echo or not event.pressed:
|
if event.echo or not event.pressed:
|
||||||
return
|
return
|
||||||
var old_pos = position_in_children
|
var old_pos = position_in_children
|
||||||
|
@ -60,13 +60,13 @@ func input_item_list(event):
|
||||||
var text = node.get_item_text(position_in_children)
|
var text = node.get_item_text(position_in_children)
|
||||||
tts.speak("%s: %s of %s" % [text, position_in_children+1, node.get_item_count()], false)
|
tts.speak("%s: %s of %s" % [text, position_in_children+1, node.get_item_count()], false)
|
||||||
|
|
||||||
func focus_label():
|
func label_focus():
|
||||||
var text = node.text
|
var text = node.text
|
||||||
if text == "":
|
if text == "":
|
||||||
text = "blank"
|
text = "blank"
|
||||||
tts.speak(text, false)
|
tts.speak(text, false)
|
||||||
|
|
||||||
func focus_line_edit():
|
func line_edit_focus():
|
||||||
var text = "blank"
|
var text = "blank"
|
||||||
if node.secret:
|
if node.secret:
|
||||||
text = "password"
|
text = "password"
|
||||||
|
@ -99,13 +99,13 @@ func check_caret_moved():
|
||||||
elif old_pos == null:
|
elif old_pos == null:
|
||||||
old_pos = pos
|
old_pos = pos
|
||||||
|
|
||||||
func focus_menu_button():
|
func menu_button_focus():
|
||||||
tts.speak(node.text + ": menu", false)
|
tts.speak(node.text + ": menu", false)
|
||||||
|
|
||||||
func focus_popup_menu():
|
func popup_menu_focus():
|
||||||
tts.speak("menu", false)
|
tts.speak("menu", false)
|
||||||
|
|
||||||
func focus_popup_menu_item(id):
|
func popup_menu_item_id_focus(id):
|
||||||
print("id: %s" % id)
|
print("id: %s" % id)
|
||||||
print("count: %s" % node.get_item_count())
|
print("count: %s" % node.get_item_count())
|
||||||
var item = node.get_item_text(id)
|
var item = node.get_item_text(id)
|
||||||
|
@ -133,7 +133,7 @@ func focus_popup_menu_item(id):
|
||||||
item += ": " + str(id + 1) + " of " + str(node.get_item_count())
|
item += ": " + str(id + 1) + " of " + str(node.get_item_count())
|
||||||
tts.speak(item, true)
|
tts.speak(item, true)
|
||||||
|
|
||||||
func render_tree_item():
|
func tree_item_render():
|
||||||
var focused_tree_item = node.get_selected()
|
var focused_tree_item = node.get_selected()
|
||||||
var result = ""
|
var result = ""
|
||||||
for i in range(node.columns):
|
for i in range(node.columns):
|
||||||
|
@ -149,14 +149,37 @@ func render_tree_item():
|
||||||
tts.speak(result, true)
|
tts.speak(result, true)
|
||||||
|
|
||||||
func tree_item_cell_selected():
|
func tree_item_cell_selected():
|
||||||
render_tree_item()
|
tree_item_render()
|
||||||
|
|
||||||
func focus_tab_container():
|
func tree_focus():
|
||||||
|
if node.get_selected():
|
||||||
|
tree_item_render()
|
||||||
|
else:
|
||||||
|
tts.speak("tree", true)
|
||||||
|
|
||||||
|
func tree_item_collapse(item):
|
||||||
|
if node.has_focus():
|
||||||
|
if item.collapsed:
|
||||||
|
tts.speak("collapsed", true)
|
||||||
|
else:
|
||||||
|
tts.speak("expanded", true)
|
||||||
|
|
||||||
|
func tree_item_select():
|
||||||
|
if node.has_focus():
|
||||||
|
tree_item_render()
|
||||||
|
|
||||||
|
func tree_item_multi_select(item, column, selected):
|
||||||
|
if selected:
|
||||||
|
tts.speak("selected", true)
|
||||||
|
else:
|
||||||
|
tts.speak("unselected", true)
|
||||||
|
|
||||||
|
func tab_container_focus():
|
||||||
var text = node.get_tab_title(node.current_tab)
|
var text = node.get_tab_title(node.current_tab)
|
||||||
text += ": tab: " + str(node.current_tab + 1) + " of " + str(node.get_tab_count())
|
text += ": tab: " + str(node.current_tab + 1) + " of " + str(node.get_tab_count())
|
||||||
tts.speak(text, false)
|
tts.speak(text, false)
|
||||||
|
|
||||||
func input_tab_container(event):
|
func tab_container_input(event):
|
||||||
if event.echo or not event.pressed:
|
if event.echo or not event.pressed:
|
||||||
return
|
return
|
||||||
var new_tab = node.current_tab
|
var new_tab = node.current_tab
|
||||||
|
@ -171,30 +194,7 @@ func input_tab_container(event):
|
||||||
if node.current_tab != new_tab:
|
if node.current_tab != new_tab:
|
||||||
node.current_tab = new_tab
|
node.current_tab = new_tab
|
||||||
tts.stop()
|
tts.stop()
|
||||||
focus_tab_container()
|
tab_container_focus()
|
||||||
|
|
||||||
func focus_tree():
|
|
||||||
if node.get_selected():
|
|
||||||
render_tree_item()
|
|
||||||
else:
|
|
||||||
tts.speak("tree", true)
|
|
||||||
|
|
||||||
func collapse_tree_item(item):
|
|
||||||
if node.has_focus():
|
|
||||||
if item.collapsed:
|
|
||||||
tts.speak("collapsed", true)
|
|
||||||
else:
|
|
||||||
tts.speak("expanded", true)
|
|
||||||
|
|
||||||
func select_tree_item():
|
|
||||||
if node.has_focus():
|
|
||||||
render_tree_item()
|
|
||||||
|
|
||||||
func multi_select_tree_item(item, column, selected):
|
|
||||||
if selected:
|
|
||||||
tts.speak("selected", true)
|
|
||||||
else:
|
|
||||||
tts.speak("unselected", true)
|
|
||||||
|
|
||||||
func focused():
|
func focused():
|
||||||
print("Focus: %s" % node)
|
print("Focus: %s" % node)
|
||||||
|
@ -203,21 +203,21 @@ func focused():
|
||||||
if parent is EditorProperty and parent.label:
|
if parent is EditorProperty and parent.label:
|
||||||
tts.speak(parent.label, false)
|
tts.speak(parent.label, false)
|
||||||
if node is MenuButton:
|
if node is MenuButton:
|
||||||
focus_menu_button()
|
menu_button_focus()
|
||||||
elif node is Button:
|
elif node is Button:
|
||||||
focus_button()
|
button_focus()
|
||||||
elif node is ItemList:
|
elif node is ItemList:
|
||||||
focus_item_list()
|
item_list_focus()
|
||||||
elif node is Label:
|
elif node is Label:
|
||||||
focus_label()
|
label_focus()
|
||||||
elif node is LineEdit:
|
elif node is LineEdit:
|
||||||
focus_line_edit()
|
line_edit_focus()
|
||||||
elif node is PopupMenu:
|
elif node is PopupMenu:
|
||||||
focus_popup_menu()
|
popup_menu_focus()
|
||||||
elif node is TabContainer:
|
elif node is TabContainer:
|
||||||
focus_tab_container()
|
tab_container_focus()
|
||||||
elif node is Tree:
|
elif node is Tree:
|
||||||
focus_tree()
|
tree_focus()
|
||||||
else:
|
else:
|
||||||
print("No handler")
|
print("No handler")
|
||||||
if node.hint_tooltip:
|
if node.hint_tooltip:
|
||||||
|
@ -228,9 +228,9 @@ func unfocused():
|
||||||
|
|
||||||
func gui_input(event):
|
func gui_input(event):
|
||||||
if node is TabContainer:
|
if node is TabContainer:
|
||||||
return input_tab_container(event)
|
return tab_container_input(event)
|
||||||
elif node is ItemList:
|
elif node is ItemList:
|
||||||
return input_item_list(event)
|
return item_list_input(event)
|
||||||
elif node is LineEdit:
|
elif node is LineEdit:
|
||||||
return check_caret_moved()
|
return check_caret_moved()
|
||||||
|
|
||||||
|
@ -257,10 +257,10 @@ func _init(tts, node):
|
||||||
# node.connect("text_deleted", self, "text_deleted")
|
# node.connect("text_deleted", self, "text_deleted")
|
||||||
# node.connect("text_inserted", self, "text_inserted")
|
# node.connect("text_inserted", self, "text_inserted")
|
||||||
elif node is PopupMenu:
|
elif node is PopupMenu:
|
||||||
node.connect("id_focused", self, "focus_popup_menu_item")
|
node.connect("id_focused", self, "popup_menu_item_id_focus")
|
||||||
elif node is Tree:
|
elif node is Tree:
|
||||||
node.connect("item_collapsed", self, "collapse_tree_item")
|
node.connect("item_collapsed", self, "tree_item_collapse")
|
||||||
node.connect("item_selected", self, "select_tree_item")
|
node.connect("item_selected", self, "tree_item_select")
|
||||||
node.connect("multi_selected", self, "multi_select_tree_item")
|
node.connect("multi_selected", self, "tree_item_multi_select")
|
||||||
node.connect("cell_selected", self, "tree_item_cell_selected")
|
node.connect("cell_selected", self, "tree_item_cell_selected")
|
||||||
node.connect("tree_exiting", self, "free")
|
node.connect("tree_exiting", self, "free")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user