- Removed more UI actions that can cause deselection of the current input field.
- UI actions are handled by functions like a real program should be doing.
This commit is contained in:
parent
3073485e92
commit
d6abe6640a
@ -35,10 +35,6 @@ func _input(event:InputEvent) -> void:
|
||||
queue_free()
|
||||
return
|
||||
|
||||
match edit_mode:
|
||||
EditMode.LINE_EDIT: line_edit.grab_focus()
|
||||
EditMode.TEXT_EDIT: text_edit.grab_focus()
|
||||
|
||||
func _exit_tree() -> void:
|
||||
__deconfigure_inputs()
|
||||
|
||||
@ -95,14 +91,14 @@ func _on_controller_input_wheel_move_caret_right() -> void:
|
||||
|
||||
|
||||
func __configure_inputs() -> void:
|
||||
__stored_ui_actions[&"ui_up"] = InputMap.action_get_events(&"ui_up")
|
||||
InputMap.action_erase_events(&"ui_up")
|
||||
__stored_ui_actions[&"ui_down"] = InputMap.action_get_events(&"ui_down")
|
||||
InputMap.action_erase_events(&"ui_down")
|
||||
__stored_ui_actions[&"ui_left"] = InputMap.action_get_events(&"ui_left")
|
||||
InputMap.action_erase_events(&"ui_left")
|
||||
__stored_ui_actions[&"ui_right"] = InputMap.action_get_events(&"ui_right")
|
||||
InputMap.action_erase_events(&"ui_right")
|
||||
__stash_ui_action(&"ui_up")
|
||||
__stash_ui_action(&"ui_down")
|
||||
__stash_ui_action(&"ui_left")
|
||||
__stash_ui_action(&"ui_right")
|
||||
__stash_ui_action(&"ui_focus_next")
|
||||
__stash_ui_action(&"ui_focus_prev")
|
||||
__stash_ui_action(&"ui_select")
|
||||
__stash_ui_action(&"ui_cancel")
|
||||
|
||||
InputMap.add_action(&"ui_exit_text_editor")
|
||||
InputMap.action_add_event(&"ui_exit_text_editor", joypad_exit)
|
||||
@ -111,35 +107,51 @@ func __deconfigure_inputs() -> void:
|
||||
InputMap.action_erase_event(&"ui_exit_text_editor", joypad_exit)
|
||||
InputMap.erase_action(&"ui_exit_text_editor")
|
||||
|
||||
for event:InputEvent in __stored_ui_actions[&"ui_right"]:
|
||||
InputMap.action_add_event(&"ui_right", event)
|
||||
for event:InputEvent in __stored_ui_actions[&"ui_left"]:
|
||||
InputMap.action_add_event(&"ui_left", event)
|
||||
for event:InputEvent in __stored_ui_actions[&"ui_down"]:
|
||||
InputMap.action_add_event(&"ui_down", event)
|
||||
for event:InputEvent in __stored_ui_actions[&"ui_up"]:
|
||||
InputMap.action_add_event(&"ui_up", event)
|
||||
__restore_ui_action(&"ui_cancel")
|
||||
__restore_ui_action(&"ui_select")
|
||||
__restore_ui_action(&"ui_focus_prev")
|
||||
__restore_ui_action(&"ui_focus_next")
|
||||
__restore_ui_action(&"ui_right")
|
||||
__restore_ui_action(&"ui_left")
|
||||
__restore_ui_action(&"ui_down")
|
||||
__restore_ui_action(&"ui_up")
|
||||
|
||||
func __stash_ui_action(action:StringName):
|
||||
__stored_ui_actions[action] = InputMap.action_get_events(action)
|
||||
InputMap.action_erase_events(action)
|
||||
|
||||
func __restore_ui_action(action:StringName):
|
||||
for event:InputEvent in __stored_ui_actions[action]:
|
||||
InputMap.action_add_event(action, event)
|
||||
|
||||
|
||||
func __set_mode(new_mode:int) -> void:
|
||||
edit_mode = new_mode
|
||||
match edit_mode:
|
||||
EditMode.LINE_EDIT:
|
||||
if line_edit: line_edit.visible = true
|
||||
if text_edit: text_edit.visible = false
|
||||
if line_edit:
|
||||
line_edit.visible = true
|
||||
line_edit.grab_focus()
|
||||
if text_edit:
|
||||
text_edit.visible = false
|
||||
EditMode.TEXT_EDIT:
|
||||
if line_edit: line_edit.visible = false
|
||||
if text_edit: text_edit.visible = true
|
||||
if line_edit:
|
||||
line_edit.visible = false
|
||||
if text_edit:
|
||||
text_edit.visible = true
|
||||
text_edit.grab_focus()
|
||||
|
||||
func __set_text(t:String) -> void:
|
||||
match edit_mode:
|
||||
EditMode.LINE_EDIT:
|
||||
line_edit.text = t
|
||||
line_edit.caret_column = t.length()
|
||||
line_edit.grab_focus()
|
||||
EditMode.TEXT_EDIT:
|
||||
text_edit.text = t
|
||||
text_edit.set_caret_line(text_edit.get_line_count()-1)
|
||||
text_edit.set_caret_column(text_edit.get_line(text_edit.get_line_count()-1).length())
|
||||
text_edit.grab_focus()
|
||||
|
||||
func __get_text() -> String:
|
||||
match edit_mode:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user