mirror of
https://github.com/lightsoutgames/godot-accessibility.git
synced 2024-11-22 11:55:56 +00:00
Very naive support for LineEdit
input, only single-character changes for now.
This commit is contained in:
parent
d0d80b1cb2
commit
723d4c298c
|
@ -141,18 +141,27 @@ func line_edit_focused():
|
||||||
type = "text"
|
type = "text"
|
||||||
TTS.speak("%s: %s" % [text, type], false)
|
TTS.speak("%s: %s" % [text, type], false)
|
||||||
|
|
||||||
func text_deleted(text):
|
var old_text
|
||||||
TTS.speak("%s deleted" % text, true)
|
|
||||||
|
|
||||||
func text_inserted(text):
|
|
||||||
TTS.speak(text, true)
|
|
||||||
|
|
||||||
var old_pos
|
var old_pos
|
||||||
|
|
||||||
|
func line_edit_text_changed(text):
|
||||||
|
if len(text) > len(old_text):
|
||||||
|
for i in range(len(text)):
|
||||||
|
if text.substr(i, 1) != old_text.substr(i, 1):
|
||||||
|
TTS.speak(text.substr(i, 1))
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
for i in range(len(old_text)):
|
||||||
|
if old_text.substr(i, 1) != text.substr(i, 1):
|
||||||
|
TTS.speak(old_text.substr(i, 1))
|
||||||
|
return
|
||||||
|
|
||||||
func line_edit_input(event):
|
func line_edit_input(event):
|
||||||
var pos = node.caret_position
|
var pos = node.caret_position
|
||||||
if old_pos != null and old_pos != pos:
|
if old_pos != null and old_pos != pos:
|
||||||
var text = node.text
|
var text = node.text
|
||||||
|
if old_text == text:
|
||||||
if pos > len(text)-1:
|
if pos > len(text)-1:
|
||||||
TTS.speak("blank", true)
|
TTS.speak("blank", true)
|
||||||
else:
|
else:
|
||||||
|
@ -160,6 +169,7 @@ func line_edit_input(event):
|
||||||
old_pos = pos
|
old_pos = pos
|
||||||
elif old_pos == null:
|
elif old_pos == null:
|
||||||
old_pos = pos
|
old_pos = pos
|
||||||
|
old_text = node.text
|
||||||
|
|
||||||
func menu_button_focused():
|
func menu_button_focused():
|
||||||
var tokens = PoolStringArray([])
|
var tokens = PoolStringArray([])
|
||||||
|
@ -509,9 +519,8 @@ func _init(node):
|
||||||
node.connect("item_selected", self, "item_list_item_selected")
|
node.connect("item_selected", self, "item_list_item_selected")
|
||||||
node.connect("multi_selected", self, "item_list_multi_selected")
|
node.connect("multi_selected", self, "item_list_multi_selected")
|
||||||
node.connect("nothing_selected", self, "item_list_nothing_selected")
|
node.connect("nothing_selected", self, "item_list_nothing_selected")
|
||||||
# elif node is LineEdit:
|
elif node is LineEdit:
|
||||||
# node.connect("text_deleted", self, "text_deleted")
|
node.connect("text_changed", self, "line_edit_text_changed")
|
||||||
# node.connect("text_inserted", self, "text_inserted")
|
|
||||||
elif node is PopupMenu:
|
elif node is PopupMenu:
|
||||||
node.connect("id_focused", self, "popup_menu_item_id_focused")
|
node.connect("id_focused", self, "popup_menu_item_id_focused")
|
||||||
node.connect("id_pressed", self, "popup_menu_item_id_pressed")
|
node.connect("id_pressed", self, "popup_menu_item_id_pressed")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user