Disabling new lines in TextEdit

Godot Version

4.4.1

Question

hiii i know this probably is a very stupid question but how can i disable new lines appearing while typying Enter in a TextEdit box. I asked Gemini about this but it doesnt seems to know either

If you only want to input one line then use a LineEdit

1 Like

Unfortunately, a LineEdit does not start edit mode when focused on whereas TextEdit does and therefore I can use it with a controller.

Came here because I had the same question. Is there a way to get a LineEdit into edit mode manually? Can’t see any methods in the docs that’d suggest that.

It’s explained in the description:

LineEdit provides an input field for editing a single line of text.

  • When the LineEdit control is focused using the keyboard arrow keys, it will only gain focus and not enter edit mode.
  • To enter edit mode, click on the control with the mouse, see also keep_editing_on_text_submit.
  • To exit edit mode, press ui_text_submit or ui_cancel (by default Escape) actions.
  • Check edit(), unedit(), is_editing(), and editing_toggled for more information.

You can call LineEdit.edit() to enter edit mode. You can do that when gaining focus for example by connecting to the Control.focus_entered signal.

1 Like

Oof, don’t know how I missed that. Thank you so much, that’s exactly what I needed!