I'm trying to create a Terminal/Debug Console-like scene.
When I press the KEY_UP key while using LineEdit, I make the text change. Then I want caret_position to come to the end of the text. But when we press the KEY_UP key, LineEdit *automatically* takes the caret_position to the *beginning*.
How can I turn off resetting this caretposition. This does not happen when using another key instead of KEYUP. Using a key other than KEY_UP for this job feels inappropriate for the job
extends Control
var texts = ["hello","world","good","day","to","you"]
var history_line = 4
func _ready():
$LineEdit.grab_focus()
$LineEdit.text = texts[history_line]
func _input(event):
if event.is_action_pressed("ui_up") :
if history_line == 0 : return
history_line -= 1
$LineEdit.text = texts[history_line]
move_cursor_to_end()
if event.is_action_pressed("ui_down") :
if history_line == texts.size() -1 :return
history_line += 1
$LineEdit.text = texts[history_line]
move_cursor_to_end()
func move_cursor_to_end() :
$LineEdit.caret_position = $LineEdit.text.length()
Godot Engine v3.2.3
English is not my first language, I'm sorry if there are mistakes