How do I set a TextEdit caret position? and is there a way to ignore Tab and Enter indentations?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IHate

I want to change the position of the caret to the end of TextEdit.text I could do this easily with a LineEdit using caret_postion() but TextEdit doesn’t have it and I want to keep the syntax highlight of TextEdit. The only solution I could come up with was to simulate inputs like control+right after setting TextEdit.text to move the caret and I was wondering if there’s a better way to accomplish this.

Also is there a way to turn off things like Tab space or Enter new line for TextEdit? I turned off shortcuts but it seem to be unrelated to these. My current solution is to yield for a frame and set Textedit.textafter the Tab or Enter keys Input has already gone through so it doesn’t display the indentations.

The solution for the second question is to manually set the inputs as handled.

func _input(event):
  if event.is_action_pressed("ui_accept") && get_focus_owner() is TextEdit:

This will give you the ability to change the functionality of the key on that Control node.

:bust_in_silhouette: Reply From: jgodfrey

You can set the cursor position in a TextEdit by line and column as shown below…


When I was reading the documentation the word column set me off my bad.

IHate | 2020-11-01 23:32