Attention | Topic was automatically imported from the old Question2Answer platform. | |
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.text
after the Tab or Enter keys Input has already gone through so it doesn’t display the indentations.
Edit:
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:
alternative_func()
get_tree().set_input_as_handled()
This will give you the ability to change the functionality of the key on that Control node.