LineEdit provides a single-line string editor, used for text fields.
It features many built-in shortcuts which will always be available ([code]Ctrl[/code] here maps to [code]Command[/code] on macOS):
- Ctrl + C: Copy
- Ctrl + X: Cut
- Ctrl + V or Ctrl + Y: Paste/"yank"
- Ctrl + Z: Undo
- Ctrl + Shift + Z: Redo
- Ctrl + U: Delete text from the cursor position to the beginning of the line
- Ctrl + K: Delete text from the cursor position to the end of the line
- Ctrl + A: Select all text
- Up/Down arrow: Move the cursor to the beginning/end of the line
On macOS, some extra keyboard shortcuts are available:
- Ctrl + F: Like the right arrow key, move the cursor one character right
- Ctrl + B: Like the left arrow key, move the cursor one character left
- Ctrl + P: Like the up arrow key, move the cursor to the previous line
- Ctrl + N: Like the down arrow key, move the cursor to the next line
- Ctrl + D: Like the Delete key, delete the character on the right side of cursor
- Ctrl + H: Like the Backspace key, delete the character on the left side of the cursor
- Command + Left arrow: Like the Home key, move the cursor to the beginning of the line
- Command + Right arrow: Like the End key, move the cursor to the end of the line
</description>
<tutorials>
</tutorials>
<methods>
<methodname="append_at_cursor">
<returntype="void"/>
<argumentindex="0"name="text"type="String"/>
<description>
Adds [code]text[/code] after the cursor. If the resulting value is longer than [member max_length], nothing happens.
</description>
</method>
<methodname="clear">
<returntype="void"/>
<description>
Erases the [LineEdit]'s [member text].
</description>
</method>
<methodname="delete_char_at_cursor">
<returntype="void"/>
<description>
Deletes one character at the cursor's current position (equivalent to pressing the [code]Delete[/code] key).
</description>
</method>
<methodname="delete_text">
<returntype="void"/>
<argumentindex="0"name="from_column"type="int"/>
<argumentindex="1"name="to_column"type="int"/>
<description>
Deletes a section of the [member text] going from position [code]from_column[/code] to [code]to_column[/code]. Both parameters should be within the text's length.
</description>
</method>
<methodname="deselect">
<returntype="void"/>
<description>
Clears the current selection.
</description>
</method>
<methodname="get_menu"qualifiers="const">
<returntype="PopupMenu"/>
<description>
Returns the [PopupMenu] of this [LineEdit]. By default, this menu is displayed when right-clicking on the [LineEdit].
[b]Warning:[/b] This is a required internal node, removing and freeing it may cause a crash. If you wish to hide it or any of its children, use their [member CanvasItem.visible] property.
Selects characters inside [LineEdit] between [code]from[/code] and [code]to[/code]. By default, [code]from[/code] is at the beginning and [code]to[/code] at the end.
If [code]true[/code], the [LineEdit] width will increase to stay longer than the [member text]. It will [b]not[/b] compress if the [member text] is shortened.
Maximum amount of characters that can be entered inside the [LineEdit]. If [code]0[/code], there is no limit.
When a limit is defined, characters that would exceed [member max_length] are truncated. This happens both for existing [member text] contents when setting the max length, or for new text inserted in the [LineEdit], including pasting. If any input text is truncated, the [signal text_change_rejected] signal is emitted with the truncated substring as parameter.
[b]Example:[/b]
[codeblock]
text = "Hello world"
max_length = 5
# `text` becomes "Hello".
max_length = 10
text += " goodbye"
# `text` becomes "Hello good".
# `text_change_rejected` is emitted with "bye" as parameter.
Sets the icon that will appear in the right end of the [LineEdit] if there's no [member text], or always, if [member clear_button_enabled] is set to [code]false[/code].
Emitted when appending text that overflows the [member max_length]. The appended text is truncated to fit [member max_length], and the part that couldn't fit is passed as the [code]rejected_substring[/code] argument.
</description>
</signal>
<signalname="text_changed">
<argumentindex="0"name="new_text"type="String"/>
<description>
Emitted when the text changes.
</description>
</signal>
<signalname="text_entered">
<argumentindex="0"name="new_text"type="String"/>
<description>
Emitted when the user presses [constant KEY_ENTER] on the [LineEdit].
</description>
</signal>
</signals>
<constants>
<constantname="ALIGN_LEFT"value="0"enum="Align">
Aligns the text on the left-hand side of the [LineEdit].
Minimum horizontal space for the text (not counting the clear button and content margins). This value is measured in count of space characters (i.e. this amount of space characters can be displayed without scrolling).