2018-05-28 16:48:02 +00:00
|
|
|
extends Object
|
|
|
|
|
|
|
|
var node
|
|
|
|
|
2018-07-19 20:12:01 +00:00
|
|
|
var position_in_children = 0
|
|
|
|
|
2019-09-03 20:57:32 +00:00
|
|
|
var column_in_row = 0
|
|
|
|
|
2019-09-04 01:27:31 +00:00
|
|
|
func get_siblings():
|
|
|
|
var parent = node.get_parent()
|
|
|
|
if parent:
|
|
|
|
return parent.get_children()
|
|
|
|
return null
|
|
|
|
|
2019-09-10 01:58:24 +00:00
|
|
|
func click(item := node, button_index = BUTTON_LEFT):
|
2019-09-04 16:32:41 +00:00
|
|
|
var click = InputEventMouseButton.new()
|
2019-09-10 01:58:24 +00:00
|
|
|
click.button_index = button_index
|
2019-09-04 16:32:41 +00:00
|
|
|
click.pressed = true
|
|
|
|
if item is Node:
|
|
|
|
click.position = item.rect_global_position
|
2019-09-10 01:58:24 +00:00
|
|
|
else:
|
|
|
|
click.position = node.get_tree().root.get_mouse_position()
|
2019-09-04 16:32:41 +00:00
|
|
|
node.get_tree().input_event(click)
|
|
|
|
click.pressed = false
|
|
|
|
node.get_tree().input_event(click)
|
2018-06-10 21:14:43 +00:00
|
|
|
|
2019-09-09 19:44:10 +00:00
|
|
|
func guess_label():
|
2019-09-24 20:13:15 +00:00
|
|
|
var tokens = PoolStringArray([])
|
|
|
|
var to_check = node
|
|
|
|
while to_check:
|
2019-10-14 14:36:08 +00:00
|
|
|
if to_check.is_class("EditorProperty") and to_check.label:
|
2019-09-24 20:13:15 +00:00
|
|
|
tokens.append(to_check.label)
|
2019-10-14 14:36:08 +00:00
|
|
|
if (to_check.is_class("EditorProperty") or to_check.is_class("EditorInspectorCategory")) and to_check.get_tooltip_text():
|
2019-09-24 20:13:15 +00:00
|
|
|
tokens.append(to_check.get_tooltip_text())
|
|
|
|
var label = tokens.join(": ")
|
|
|
|
if label:
|
|
|
|
return label
|
|
|
|
to_check = to_check.get_parent()
|
2019-09-09 19:44:10 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func accept_dialog_focused():
|
2019-09-25 14:07:26 +00:00
|
|
|
yield(node.get_tree().create_timer(5), "timeout")
|
|
|
|
node.get_ok().emit_signal("pressed")
|
2019-09-05 14:01:20 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func checkbox_focused():
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
2019-09-09 13:35:05 +00:00
|
|
|
if node.pressed:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("checked")
|
2019-09-09 13:35:05 +00:00
|
|
|
else:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("unchecked")
|
|
|
|
tokens.append(" checkbox")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(" "), false)
|
2019-09-09 13:35:05 +00:00
|
|
|
|
|
|
|
func checkbox_toggled(checked):
|
2019-09-30 14:47:42 +00:00
|
|
|
if node.has_focus():
|
|
|
|
if checked:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("checked", true)
|
2019-09-30 14:47:42 +00:00
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("unchecked", true)
|
2019-09-09 13:35:05 +00:00
|
|
|
|
2019-09-10 02:36:09 +00:00
|
|
|
var spoke_hint_tooltip
|
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func button_focused():
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
2018-06-10 20:32:27 +00:00
|
|
|
if node.text:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append(node.text)
|
|
|
|
elif node.hint_tooltip:
|
|
|
|
spoke_hint_tooltip = true
|
|
|
|
tokens.append(node.hint_tooltip)
|
|
|
|
tokens.append("button")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), false)
|
2018-06-10 20:32:27 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func texturebutton_focused():
|
2019-10-08 13:56:51 +00:00
|
|
|
var texture = node.texture_normal
|
|
|
|
print(texture.resource_name)
|
|
|
|
print(texture.resource_path)
|
|
|
|
var rid = texture.get_rid()
|
|
|
|
print(rid)
|
|
|
|
print(rid.get_id())
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("button", false)
|
2019-09-04 16:32:41 +00:00
|
|
|
|
2019-09-25 22:18:01 +00:00
|
|
|
func item_list_item_focused(idx):
|
|
|
|
var tokens = PoolStringArray([])
|
|
|
|
var text = node.get_item_text(idx)
|
|
|
|
if text:
|
|
|
|
tokens.append(text)
|
|
|
|
text = node.get_item_tooltip(idx)
|
|
|
|
if text:
|
|
|
|
tokens.append(text)
|
|
|
|
tokens.append("%s of %s" % [idx + 1, node.get_item_count()])
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "))
|
2019-09-25 22:18:01 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func item_list_focused():
|
2018-07-03 17:01:00 +00:00
|
|
|
var count = node.get_item_count()
|
2019-10-10 14:49:54 +00:00
|
|
|
var selected = node.get_selected_items()
|
|
|
|
print(selected)
|
|
|
|
if len(selected) == 0:
|
|
|
|
if node.get_item_count() == 0:
|
|
|
|
return TTS.speak("list, 0 items", false)
|
|
|
|
selected = 0
|
|
|
|
node.select(selected)
|
|
|
|
node.emit_signal("item_list_item_selected", selected)
|
|
|
|
else:
|
|
|
|
selected = selected[0]
|
2019-09-25 22:18:01 +00:00
|
|
|
position_in_children = selected
|
|
|
|
item_list_item_focused(selected)
|
2018-07-03 17:01:00 +00:00
|
|
|
|
2019-09-02 12:04:45 +00:00
|
|
|
func item_list_item_selected(index):
|
2019-10-10 14:49:54 +00:00
|
|
|
item_list_item_focused(index)
|
2018-07-03 17:01:00 +00:00
|
|
|
|
2019-09-02 12:04:45 +00:00
|
|
|
func item_list_multi_selected(index, selected):
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("Multiselect", false)
|
2018-07-03 17:01:00 +00:00
|
|
|
|
2019-09-02 12:04:45 +00:00
|
|
|
func item_list_nothing_selected():
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("Nothing selected", true)
|
2018-07-03 17:01:00 +00:00
|
|
|
|
2019-09-03 21:45:46 +00:00
|
|
|
func item_list_input(event):
|
2019-10-08 19:29:20 +00:00
|
|
|
if event.is_action_pressed("ui_right") or event.is_action_pressed("ui_left"):
|
|
|
|
return node.accept_event()
|
|
|
|
var old_count = node.get_item_count()
|
2019-09-03 20:57:32 +00:00
|
|
|
var old_pos = position_in_children
|
2019-09-05 14:01:20 +00:00
|
|
|
if event.is_action_pressed("ui_up"):
|
|
|
|
node.accept_event()
|
2018-07-19 20:12:01 +00:00
|
|
|
if position_in_children == 0:
|
2018-07-03 16:39:43 +00:00
|
|
|
return
|
2018-07-19 20:12:01 +00:00
|
|
|
position_in_children -= 1
|
2019-09-05 14:01:20 +00:00
|
|
|
elif event.is_action_pressed("ui_down"):
|
|
|
|
node.accept_event()
|
2018-07-19 20:12:01 +00:00
|
|
|
if position_in_children >= node.get_item_count()-1:
|
2018-07-03 16:39:43 +00:00
|
|
|
return
|
2018-07-19 20:12:01 +00:00
|
|
|
position_in_children += 1
|
2019-09-05 14:01:20 +00:00
|
|
|
elif event.is_action_pressed("ui_home"):
|
|
|
|
node.accept_event()
|
2018-07-19 20:12:01 +00:00
|
|
|
position_in_children = 0
|
2019-09-05 14:01:20 +00:00
|
|
|
elif event.is_action_pressed("ui_end"):
|
|
|
|
node.accept_event()
|
2018-07-19 20:12:01 +00:00
|
|
|
position_in_children = node.get_item_count()-1
|
|
|
|
if old_pos != position_in_children:
|
2019-10-08 19:29:20 +00:00
|
|
|
if position_in_children >= node.get_item_count():
|
|
|
|
position_in_children = 0
|
2019-09-25 22:18:01 +00:00
|
|
|
node.unselect_all()
|
|
|
|
node.select(position_in_children)
|
2019-10-10 14:49:54 +00:00
|
|
|
node.emit_signal("item_list_item_selected", position_in_children)
|
2019-09-25 22:18:01 +00:00
|
|
|
item_list_item_focused(position_in_children)
|
2018-06-10 21:14:43 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func label_focused():
|
2019-09-02 12:04:45 +00:00
|
|
|
var text = node.text
|
|
|
|
if text == "":
|
|
|
|
text = "blank"
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(text, false)
|
2018-07-19 20:20:48 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func line_edit_focused():
|
2018-06-10 20:32:27 +00:00
|
|
|
var text = "blank"
|
|
|
|
if node.secret:
|
|
|
|
text = "password"
|
|
|
|
elif node.text != "":
|
|
|
|
text = node.text
|
|
|
|
elif node.placeholder_text != "":
|
|
|
|
text = node.placeholder_text
|
|
|
|
var type = "editable text"
|
|
|
|
if not node.editable:
|
|
|
|
type = "text"
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("%s: %s" % [text, type], false)
|
2018-06-10 20:32:27 +00:00
|
|
|
|
2019-10-03 15:28:54 +00:00
|
|
|
var old_text
|
2018-07-03 15:45:31 +00:00
|
|
|
|
2018-06-18 20:33:03 +00:00
|
|
|
var old_pos
|
|
|
|
|
2019-10-03 15:28:54 +00:00
|
|
|
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
|
|
|
|
|
2019-09-26 12:52:51 +00:00
|
|
|
func line_edit_input(event):
|
2018-06-12 12:32:09 +00:00
|
|
|
var pos = node.caret_position
|
2019-09-02 12:48:50 +00:00
|
|
|
if old_pos != null and old_pos != pos:
|
2018-06-18 20:33:03 +00:00
|
|
|
var text = node.text
|
2019-10-03 15:28:54 +00:00
|
|
|
if old_text == text:
|
|
|
|
if pos > len(text)-1:
|
|
|
|
TTS.speak("blank", true)
|
|
|
|
else:
|
|
|
|
TTS.speak(text[pos], true)
|
2018-06-18 20:33:03 +00:00
|
|
|
old_pos = pos
|
2019-09-02 12:48:50 +00:00
|
|
|
elif old_pos == null:
|
|
|
|
old_pos = pos
|
2019-10-03 15:28:54 +00:00
|
|
|
old_text = node.text
|
2018-06-12 12:32:09 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func menu_button_focused():
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
|
|
|
if node.text:
|
|
|
|
tokens.append(node.text)
|
|
|
|
if node.hint_tooltip:
|
|
|
|
tokens.append(node.hint_tooltip)
|
|
|
|
spoke_hint_tooltip = true
|
|
|
|
tokens.append("menu")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), false)
|
2019-09-02 12:04:45 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func popup_menu_focused():
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("menu", false)
|
2018-07-19 20:12:01 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func popup_menu_item_id_focused(index):
|
2019-09-30 20:15:00 +00:00
|
|
|
print("item id focus %s" % index)
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
2019-09-30 20:15:00 +00:00
|
|
|
var shortcut = node.get_item_shortcut(index)
|
|
|
|
if shortcut:
|
|
|
|
var name = shortcut.resource_name
|
|
|
|
if name:
|
|
|
|
tokens.append(name)
|
|
|
|
var text = shortcut.get_as_text()
|
|
|
|
if text != "None":
|
|
|
|
tokens.append(text)
|
2019-09-10 01:58:24 +00:00
|
|
|
var item = node.get_item_text(index)
|
2019-09-10 02:36:09 +00:00
|
|
|
if item:
|
|
|
|
tokens.append(item)
|
2019-09-10 01:58:24 +00:00
|
|
|
var submenu = node.get_item_submenu(index)
|
2019-09-10 02:36:09 +00:00
|
|
|
if submenu:
|
|
|
|
tokens.append(submenu)
|
|
|
|
tokens.append("menu")
|
2019-09-30 20:15:00 +00:00
|
|
|
if node.is_item_checkable(index):
|
|
|
|
if node.is_item_checked(index):
|
|
|
|
tokens.append("checked")
|
|
|
|
else:
|
|
|
|
tokens.append("unchecked")
|
2019-09-10 01:58:24 +00:00
|
|
|
var tooltip = node.get_item_tooltip(index)
|
2019-09-10 02:36:09 +00:00
|
|
|
if tooltip:
|
|
|
|
tokens.append(tooltip)
|
2019-09-10 01:58:24 +00:00
|
|
|
var disabled = node.is_item_disabled(index)
|
2019-09-10 02:36:09 +00:00
|
|
|
if disabled:
|
|
|
|
tokens.append("disabled")
|
2019-09-21 14:19:00 +00:00
|
|
|
tokens.append(str(index + 1) + " of " + str(node.get_item_count()))
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), true)
|
2018-07-19 20:12:01 +00:00
|
|
|
|
2019-09-30 20:15:00 +00:00
|
|
|
func popup_menu_item_id_pressed(index):
|
|
|
|
if node.is_item_checkable(index):
|
|
|
|
if node.is_item_checked(index):
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("checked", true)
|
2019-09-30 20:15:00 +00:00
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("unchecked", true)
|
2019-09-30 20:15:00 +00:00
|
|
|
|
|
|
|
|
2019-09-03 21:45:46 +00:00
|
|
|
func tree_item_render():
|
2019-09-03 21:33:02 +00:00
|
|
|
var focused_tree_item = node.get_selected()
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
2019-09-03 17:54:19 +00:00
|
|
|
for i in range(node.columns):
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append(focused_tree_item.get_text(i))
|
2019-09-03 20:57:32 +00:00
|
|
|
if focused_tree_item.get_children():
|
|
|
|
if focused_tree_item.collapsed:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("collapsed")
|
2019-09-03 20:57:32 +00:00
|
|
|
else:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("expanded")
|
|
|
|
tokens.append("tree item")
|
2019-09-03 20:57:32 +00:00
|
|
|
if focused_tree_item.is_selected(0):
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("selected")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), true)
|
2018-07-19 17:02:40 +00:00
|
|
|
|
2019-09-20 15:28:17 +00:00
|
|
|
func tree_item_deselect_all(item: TreeItem):
|
|
|
|
for i in range(node.columns):
|
|
|
|
item.deselect(i)
|
|
|
|
|
|
|
|
func tree_deselect_all_but(target: TreeItem, item: TreeItem):
|
2019-09-21 14:47:15 +00:00
|
|
|
var next = item.get_next_visible()
|
|
|
|
while next and next != item:
|
2019-09-20 15:28:17 +00:00
|
|
|
tree_item_deselect_all(item)
|
2019-09-21 14:47:15 +00:00
|
|
|
next = next.get_next_visible()
|
2019-09-20 15:28:17 +00:00
|
|
|
|
2019-09-03 22:22:02 +00:00
|
|
|
var prev_selected_cell
|
|
|
|
|
2019-09-04 16:32:41 +00:00
|
|
|
var button_index
|
|
|
|
|
2019-09-03 22:22:02 +00:00
|
|
|
func tree_item_selected():
|
2019-09-04 16:32:41 +00:00
|
|
|
button_index = null
|
2019-09-03 22:22:02 +00:00
|
|
|
var cell = node.get_selected()
|
2019-09-24 19:42:46 +00:00
|
|
|
if cell != prev_selected_cell:
|
2019-09-20 15:28:17 +00:00
|
|
|
if node.select_mode == Tree.SELECT_MULTI:
|
2019-09-24 19:42:46 +00:00
|
|
|
cell.select(0)
|
2019-09-20 15:28:17 +00:00
|
|
|
tree_deselect_all_but(cell, node.get_root())
|
2019-10-03 14:47:24 +00:00
|
|
|
if node.has_focus():
|
|
|
|
tree_item_render()
|
2019-09-03 22:22:02 +00:00
|
|
|
prev_selected_cell = cell
|
|
|
|
else:
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
2019-09-03 22:22:02 +00:00
|
|
|
for i in range(node.columns):
|
|
|
|
if cell.is_selected(i):
|
|
|
|
var title = node.get_column_title(i)
|
|
|
|
if title:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append(title)
|
2019-09-04 16:32:41 +00:00
|
|
|
var column_text = cell.get_text(i)
|
|
|
|
if column_text:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append(column_text)
|
2019-09-04 16:32:41 +00:00
|
|
|
var button_count = cell.get_button_count(i)
|
|
|
|
if button_count != 0:
|
|
|
|
button_index = 0
|
2019-10-02 21:20:25 +00:00
|
|
|
tokens.append(str(button_count) + " " + TTS.singular_or_plural(button_count, "button", "buttons"))
|
2019-09-24 20:13:15 +00:00
|
|
|
if cell.has_method("get_button_tooltip"):
|
|
|
|
var button_tooltip = cell.get_button_tooltip(i, button_index)
|
|
|
|
if button_tooltip:
|
|
|
|
tokens.append(button_tooltip)
|
|
|
|
tokens.append("button")
|
|
|
|
if button_count > 1:
|
|
|
|
tokens.append("Use Home and End to switch focus.")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), true)
|
2019-09-03 22:22:02 +00:00
|
|
|
|
|
|
|
func tree_item_multi_select(item, column, selected):
|
|
|
|
if selected:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("selected", true)
|
2019-09-03 22:22:02 +00:00
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("unselected", true)
|
2019-09-03 21:33:02 +00:00
|
|
|
|
2019-09-04 16:32:41 +00:00
|
|
|
func tree_input(event):
|
|
|
|
var item = node.get_selected()
|
|
|
|
var column
|
|
|
|
if item:
|
|
|
|
for i in range(node.columns):
|
|
|
|
if item.is_selected(i):
|
|
|
|
column = i
|
2019-09-05 14:01:20 +00:00
|
|
|
break
|
2019-09-10 01:58:24 +00:00
|
|
|
if item and event is InputEventKey and event.pressed and not event.echo:
|
|
|
|
var area
|
|
|
|
if column:
|
|
|
|
area = node.get_item_area_rect(item, column)
|
|
|
|
else:
|
|
|
|
area = node.get_item_area_rect(item)
|
2019-09-30 19:48:11 +00:00
|
|
|
var position = Vector2(node.rect_global_position.x + area.position.x + area.size.x / 2, node.rect_global_position.y + area.position.y + area.size.y / 2)
|
2019-09-10 01:58:24 +00:00
|
|
|
node.get_tree().root.warp_mouse(position)
|
2019-09-04 16:32:41 +00:00
|
|
|
if item and column and button_index != null:
|
2019-09-05 14:01:20 +00:00
|
|
|
if event.is_action_pressed("ui_accept"):
|
2019-09-04 16:32:41 +00:00
|
|
|
node.accept_event()
|
|
|
|
return node.emit_signal("button_pressed", item, column, button_index + 1)
|
|
|
|
var new_button_index = button_index
|
2019-09-05 14:01:20 +00:00
|
|
|
if event.is_action_pressed("ui_home"):
|
2019-09-04 16:32:41 +00:00
|
|
|
node.accept_event()
|
|
|
|
new_button_index += 1
|
|
|
|
if new_button_index >= item.get_button_count(column):
|
|
|
|
new_button_index = 0
|
2019-09-05 14:01:20 +00:00
|
|
|
elif event.is_action_pressed("ui_end"):
|
2019-09-04 16:32:41 +00:00
|
|
|
node.accept_event()
|
|
|
|
new_button_index -= 1
|
|
|
|
if new_button_index < 0:
|
|
|
|
new_button_index = item.get_button_count(column) - 1
|
2019-09-24 20:13:15 +00:00
|
|
|
if new_button_index != button_index and item.has_method("get_button_tooltip"):
|
2019-09-04 16:32:41 +00:00
|
|
|
button_index = new_button_index
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray([])
|
2019-09-04 16:32:41 +00:00
|
|
|
var tooltip = item.get_button_tooltip(column, button_index)
|
|
|
|
if tooltip:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append(tooltip)
|
|
|
|
tokens.append("button")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), true)
|
2019-09-04 16:32:41 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func tree_focused():
|
2019-09-03 21:45:46 +00:00
|
|
|
if node.get_selected():
|
|
|
|
tree_item_render()
|
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("tree", true)
|
2019-09-03 21:45:46 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func tree_item_collapsed(item):
|
2019-09-03 21:45:46 +00:00
|
|
|
if node.has_focus():
|
|
|
|
if item.collapsed:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("collapsed", true)
|
2019-09-03 21:45:46 +00:00
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("expanded", true)
|
2019-09-03 21:45:46 +00:00
|
|
|
|
2019-10-08 13:56:51 +00:00
|
|
|
func progress_bar_focused():
|
|
|
|
var percentage = int(node.ratio * 100)
|
|
|
|
TTS.speak("%s percent" % percentage, false)
|
|
|
|
TTS.speak("progress bar", false)
|
|
|
|
|
|
|
|
var last_percentage_spoken
|
|
|
|
|
|
|
|
var last_percentage_spoken_at = 0
|
|
|
|
|
|
|
|
func progress_bar_value_changed(value):
|
|
|
|
var percentage = node.value / (node.max_value - node.min_value) * 100
|
|
|
|
percentage = int(percentage)
|
|
|
|
if percentage != last_percentage_spoken and OS.get_ticks_msec() - last_percentage_spoken_at >= 10000:
|
|
|
|
TTS.speak("%s percent" % percentage)
|
|
|
|
last_percentage_spoken_at = OS.get_ticks_msec()
|
|
|
|
last_percentage_spoken = percentage
|
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func tab_container_focused():
|
2019-09-02 14:55:51 +00:00
|
|
|
var text = node.get_tab_title(node.current_tab)
|
|
|
|
text += ": tab: " + str(node.current_tab + 1) + " of " + str(node.get_tab_count())
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(text, false)
|
2019-09-02 14:55:51 +00:00
|
|
|
|
2019-09-05 14:16:25 +00:00
|
|
|
func tab_container_tab_changed(tab):
|
2019-09-21 13:54:12 +00:00
|
|
|
if node.has_focus():
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.stop()
|
2019-10-03 14:41:49 +00:00
|
|
|
tab_container_focused()
|
2019-09-05 14:16:25 +00:00
|
|
|
|
2019-09-03 21:45:46 +00:00
|
|
|
func tab_container_input(event):
|
2019-09-02 16:08:10 +00:00
|
|
|
var new_tab = node.current_tab
|
2019-09-05 14:01:20 +00:00
|
|
|
if event.is_action_pressed("ui_right"):
|
|
|
|
node.accept_event()
|
2019-09-02 14:55:51 +00:00
|
|
|
new_tab += 1
|
2019-09-05 14:01:20 +00:00
|
|
|
elif event.is_action_pressed("ui_left"):
|
|
|
|
node.accept_event()
|
2019-09-02 14:55:51 +00:00
|
|
|
new_tab -= 1
|
|
|
|
if new_tab < 0:
|
|
|
|
new_tab = node.get_tab_count() - 1
|
|
|
|
elif new_tab >= node.get_tab_count():
|
|
|
|
new_tab = 0
|
2019-09-03 17:58:47 +00:00
|
|
|
if node.current_tab != new_tab:
|
|
|
|
node.current_tab = new_tab
|
2018-06-10 21:02:45 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func focused():
|
2019-09-02 12:04:45 +00:00
|
|
|
print("Focus: %s" % node)
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.stop()
|
2019-09-09 19:44:10 +00:00
|
|
|
var label = guess_label()
|
|
|
|
if label:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(label, false)
|
2018-07-19 20:12:01 +00:00
|
|
|
if node is MenuButton:
|
2019-10-03 14:41:49 +00:00
|
|
|
menu_button_focused()
|
2019-09-05 14:01:20 +00:00
|
|
|
elif node is AcceptDialog:
|
2019-10-03 14:41:49 +00:00
|
|
|
accept_dialog_focused()
|
2019-09-09 13:35:05 +00:00
|
|
|
elif node is CheckBox:
|
2019-10-03 14:41:49 +00:00
|
|
|
checkbox_focused()
|
2018-07-19 20:12:01 +00:00
|
|
|
elif node is Button:
|
2019-10-03 14:41:49 +00:00
|
|
|
button_focused()
|
2019-10-14 14:36:08 +00:00
|
|
|
elif node.is_class("EditorInspectorSection"):
|
2019-10-03 14:41:49 +00:00
|
|
|
editor_inspector_section_focused()
|
2018-06-10 21:14:43 +00:00
|
|
|
elif node is ItemList:
|
2019-10-03 14:41:49 +00:00
|
|
|
item_list_focused()
|
2018-07-19 20:20:48 +00:00
|
|
|
elif node is Label:
|
2019-10-03 14:41:49 +00:00
|
|
|
label_focused()
|
2018-06-10 20:32:27 +00:00
|
|
|
elif node is LineEdit:
|
2019-10-03 14:41:49 +00:00
|
|
|
line_edit_focused()
|
2019-10-08 13:56:51 +00:00
|
|
|
elif node is LinkButton:
|
|
|
|
button_focused()
|
2018-07-19 20:12:01 +00:00
|
|
|
elif node is PopupMenu:
|
2019-10-03 14:41:49 +00:00
|
|
|
popup_menu_focused()
|
2019-10-08 13:56:51 +00:00
|
|
|
elif node is ProgressBar:
|
|
|
|
progress_bar_focused()
|
2019-09-02 14:55:51 +00:00
|
|
|
elif node is TabContainer:
|
2019-10-03 14:41:49 +00:00
|
|
|
tab_container_focused()
|
2019-09-04 16:32:41 +00:00
|
|
|
elif node is TextureButton:
|
2019-10-03 14:41:49 +00:00
|
|
|
texturebutton_focused()
|
2018-06-10 21:02:45 +00:00
|
|
|
elif node is Tree:
|
2019-10-03 14:41:49 +00:00
|
|
|
tree_focused()
|
2018-06-10 20:18:00 +00:00
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(node.get_class(), true)
|
2019-09-02 12:04:45 +00:00
|
|
|
print("No handler")
|
2019-09-10 02:36:09 +00:00
|
|
|
if node.hint_tooltip and not spoke_hint_tooltip:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(node.hint_tooltip, false)
|
2019-09-10 02:36:09 +00:00
|
|
|
spoke_hint_tooltip = false
|
2018-05-28 16:48:02 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func unfocused():
|
2019-09-07 17:26:50 +00:00
|
|
|
print("Unfocused")
|
2018-07-19 20:12:01 +00:00
|
|
|
position_in_children = 0
|
2019-09-25 14:15:49 +00:00
|
|
|
yield(node.get_tree().create_timer(1), "timeout")
|
|
|
|
if not node.get_focus_owner():
|
|
|
|
node.get_tree().root.warp_mouse(node.rect_global_position)
|
2018-05-28 21:09:29 +00:00
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func click_focused():
|
2019-09-10 01:58:24 +00:00
|
|
|
if node.has_focus():
|
|
|
|
return
|
2019-10-03 14:34:22 +00:00
|
|
|
if node.focus_mode == Control.FOCUS_ALL:
|
|
|
|
print("Grabbing focus: %s" % node)
|
|
|
|
node.grab_focus()
|
2019-09-10 01:58:24 +00:00
|
|
|
|
2018-06-10 19:42:58 +00:00
|
|
|
func gui_input(event):
|
2019-09-30 20:15:00 +00:00
|
|
|
if event is InputEventKey and Input.is_action_just_pressed("ui_accept") and event.control and event.alt:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("click", false)
|
2019-09-30 20:15:00 +00:00
|
|
|
click()
|
|
|
|
elif event is InputEventKey and event.pressed and not event.echo and event.scancode == KEY_MENU:
|
2019-09-21 14:19:00 +00:00
|
|
|
node.get_tree().root.warp_mouse(node.rect_global_position)
|
2019-09-10 01:58:24 +00:00
|
|
|
return click(null, BUTTON_RIGHT)
|
2019-09-02 14:55:51 +00:00
|
|
|
if node is TabContainer:
|
2019-09-03 21:45:46 +00:00
|
|
|
return tab_container_input(event)
|
2019-09-03 17:54:19 +00:00
|
|
|
elif node is ItemList:
|
2019-09-03 21:45:46 +00:00
|
|
|
return item_list_input(event)
|
2018-07-19 20:12:01 +00:00
|
|
|
elif node is LineEdit:
|
2019-09-26 12:52:51 +00:00
|
|
|
return line_edit_input(event)
|
2019-09-04 16:32:41 +00:00
|
|
|
elif node is Tree:
|
2019-09-25 14:12:40 +00:00
|
|
|
if event.is_action_pressed("ui_up") or event.is_action_pressed("ui_down") or event.is_action_pressed("ui_left") or event.is_action_pressed("ui_right"):
|
|
|
|
node.accept_event()
|
2019-09-04 16:32:41 +00:00
|
|
|
return tree_input(event)
|
2019-10-14 14:36:08 +00:00
|
|
|
elif node.is_class("EditorInspectorSection"):
|
2019-09-04 16:32:41 +00:00
|
|
|
return editor_inspector_section_input(event)
|
2019-09-04 01:27:31 +00:00
|
|
|
elif event.is_action_pressed("ui_left"):
|
|
|
|
return node.accept_event()
|
|
|
|
elif event.is_action_pressed("ui_right"):
|
|
|
|
return node.accept_event()
|
|
|
|
elif event.is_action_pressed("ui_up"):
|
|
|
|
return node.accept_event()
|
|
|
|
elif event.is_action_pressed("ui_down"):
|
|
|
|
return node.accept_event()
|
2019-09-26 14:03:46 +00:00
|
|
|
|
|
|
|
func is_in_bar():
|
2019-09-04 01:27:31 +00:00
|
|
|
var parent = node.get_parent()
|
|
|
|
if parent and parent is Container:
|
|
|
|
for child in parent.get_children():
|
|
|
|
if child and not is_focusable(child):
|
|
|
|
return false
|
|
|
|
return true
|
|
|
|
return false
|
2018-05-28 16:48:02 +00:00
|
|
|
|
2019-09-04 01:27:31 +00:00
|
|
|
func is_focusable(node):
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("SceneTreeEditor"):
|
2019-09-30 20:24:02 +00:00
|
|
|
return false
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("MultiMeshEditor"):
|
2019-09-30 20:24:02 +00:00
|
|
|
return false
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("MeshInstanceEditor"):
|
2019-09-30 20:24:02 +00:00
|
|
|
return false
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("SpriteEditor"):
|
2019-09-30 20:24:02 +00:00
|
|
|
return false
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("Skeleton2DEditor"):
|
2019-09-30 20:24:02 +00:00
|
|
|
return false
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("CollisionShape2DEditor"):
|
2019-09-30 20:24:02 +00:00
|
|
|
return false
|
2019-10-03 14:34:22 +00:00
|
|
|
if node is Panel:
|
|
|
|
return false
|
2019-09-03 22:43:20 +00:00
|
|
|
if node is TabContainer:
|
|
|
|
return true
|
2019-10-14 14:36:08 +00:00
|
|
|
if node.is_class("EditorInspectorSection"):
|
2019-09-04 16:32:41 +00:00
|
|
|
return true
|
2019-09-17 15:42:58 +00:00
|
|
|
if node is Container or node is Separator or node is ScrollBar or node is Popup or node.get_class() == "Control":
|
2019-09-03 22:43:20 +00:00
|
|
|
return false
|
|
|
|
return true
|
|
|
|
|
2019-10-03 14:41:49 +00:00
|
|
|
func editor_inspector_section_focused():
|
2019-09-07 17:50:01 +00:00
|
|
|
var child = node.get_children()[0]
|
|
|
|
var expanded = child.is_visible_in_tree()
|
2019-09-10 02:36:09 +00:00
|
|
|
var tokens = PoolStringArray(["editor inspector section"])
|
2019-09-07 17:50:01 +00:00
|
|
|
if expanded:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("expanded")
|
2019-09-07 17:50:01 +00:00
|
|
|
else:
|
2019-09-10 02:36:09 +00:00
|
|
|
tokens.append("collapsed")
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak(tokens.join(": "), false)
|
2019-09-04 16:32:41 +00:00
|
|
|
|
|
|
|
func editor_inspector_section_input(event):
|
2019-09-05 14:01:20 +00:00
|
|
|
if event.is_action_pressed("ui_accept"):
|
2019-09-10 01:58:24 +00:00
|
|
|
click()
|
2019-09-07 17:50:01 +00:00
|
|
|
var child = node.get_children()[0]
|
|
|
|
var expanded = child.is_visible_in_tree()
|
|
|
|
if expanded:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("expanded", true)
|
2019-09-07 17:50:01 +00:00
|
|
|
else:
|
2019-10-02 21:20:25 +00:00
|
|
|
TTS.speak("collapsed", true)
|
2019-09-04 16:32:41 +00:00
|
|
|
|
2019-10-02 21:20:25 +00:00
|
|
|
func _init(node):
|
2018-06-07 21:18:36 +00:00
|
|
|
if node.is_in_group("accessible"):
|
|
|
|
return
|
|
|
|
node.add_to_group("accessible")
|
2018-05-28 16:48:02 +00:00
|
|
|
self.node = node
|
2019-09-04 01:27:31 +00:00
|
|
|
if is_focusable(node):
|
2019-09-02 14:55:51 +00:00
|
|
|
node.set_focus_mode(Control.FOCUS_ALL)
|
2019-10-03 14:41:49 +00:00
|
|
|
node.connect("focus_entered", self, "focused")
|
|
|
|
node.connect("mouse_entered", self, "click_focused")
|
|
|
|
node.connect("focus_exited", self, "unfocused")
|
|
|
|
node.connect("mouse_exited", self, "unfocused")
|
2018-07-03 16:42:00 +00:00
|
|
|
node.connect("gui_input", self, "gui_input")
|
2019-09-09 13:35:05 +00:00
|
|
|
if node is CheckBox:
|
|
|
|
node.connect("toggled", self, "checkbox_toggled")
|
|
|
|
elif node is ItemList:
|
2019-09-02 12:04:45 +00:00
|
|
|
node.connect("item_selected", self, "item_list_item_selected")
|
|
|
|
node.connect("multi_selected", self, "item_list_multi_selected")
|
|
|
|
node.connect("nothing_selected", self, "item_list_nothing_selected")
|
2019-10-03 15:28:54 +00:00
|
|
|
elif node is LineEdit:
|
|
|
|
node.connect("text_changed", self, "line_edit_text_changed")
|
2018-07-19 20:12:01 +00:00
|
|
|
elif node is PopupMenu:
|
2019-10-03 14:41:49 +00:00
|
|
|
node.connect("id_focused", self, "popup_menu_item_id_focused")
|
2019-09-30 20:15:00 +00:00
|
|
|
node.connect("id_pressed", self, "popup_menu_item_id_pressed")
|
2019-10-08 13:56:51 +00:00
|
|
|
elif node is ProgressBar:
|
|
|
|
node.connect("value_changed", self, "progress_bar_value_changed")
|
2019-09-05 14:16:25 +00:00
|
|
|
elif node is TabContainer:
|
|
|
|
node.connect("tab_changed", self, "tab_container_tab_changed")
|
2018-07-19 17:02:40 +00:00
|
|
|
elif node is Tree:
|
2019-10-03 14:41:49 +00:00
|
|
|
node.connect("item_collapsed", self, "tree_item_collapsed")
|
|
|
|
node.connect("multi_selected", self, "tree_item_multi_selected")
|
2019-09-03 22:22:02 +00:00
|
|
|
if node.select_mode == Tree.SELECT_MULTI:
|
|
|
|
node.connect("cell_selected", self, "tree_item_selected")
|
|
|
|
else:
|
|
|
|
node.connect("item_selected", self, "tree_item_selected")
|
2019-09-25 12:31:18 +00:00
|
|
|
node.connect("tree_exiting", self, "free")
|