LineEdit provides an input field for editing a single line of text. It features many built-in shortcuts that are always available (Ctrl here maps to Cmd on macOS):
Ctrl + C: Copy
Ctrl + X: Cut
Ctrl + V or Ctrl + Y: Paste/"yank"
Ctrl + Z: Undo
Ctrl + ~: Swap input direction.
Ctrl + Shift + Z: Redo
Ctrl + U: Delete text from the caret position to the beginning of the line
Ctrl + K: Delete text from the caret position to the end of the line
Ctrl + A: Select all text
Up Arrow/Down Arrow: Move the caret to the beginning/end of the line
On macOS, some extra keyboard shortcuts are available:
Cmd + F: Same as Right Arrow, move the caret one character right
Cmd + B: Same as Left Arrow, move the caret one character left
Cmd + P: Same as Up Arrow, move the caret to the previous line
Cmd + N: Same as Down Arrow, move the caret to the next line
Cmd + D: Same as Delete, delete the character on the right side of caret
Cmd + H: Same as Backspace, delete the character on the left side of the caret
Cmd + A: Same as Home, move the caret to the beginning of the line
Cmd + E: Same as End, move the caret to the end of the line
Cmd + Left Arrow: Same as Home, move the caret to the beginning of the line
Cmd + Right Arrow: Same as End, move the caret to the end of the line
Emitted when appending text that overflows the max_length. The appended text is truncated to fit max_length, and the part that couldn't fit is passed as the rejected_substring
argument.
Emitted when the text changes.
Emitted when the user presses @GlobalScope.KEY_ENTER on the LineEdit.
Cuts (copies and clears) the selected text.
Copies the selected text.
Pastes the clipboard text over the selected text (or at the caret's position).
Erases the whole LineEdit text.
Selects the whole LineEdit text.
Undoes the previous action.
Reverse the last undo action.
ID of "Text Writing Direction" submenu.
Sets text direction to inherited.
Sets text direction to automatic.
Sets text direction to left-to-right.
Sets text direction to right-to-left.
Toggles control character display.
ID of "Insert Control Character" submenu.
Inserts left-to-right mark (LRM) character.
Inserts right-to-left mark (RLM) character.
Inserts start of left-to-right embedding (LRE) character.
Inserts start of right-to-left embedding (RLE) character.
Inserts start of left-to-right override (LRO) character.
Inserts start of right-to-left override (RLO) character.
Inserts pop direction formatting (PDF) character.
Inserts Arabic letter mark (ALM) character.
Inserts left-to-right isolate (LRI) character.
Inserts right-to-left isolate (RLI) character.
Inserts first strong isolate (FSI) character.
Inserts pop direction isolate (PDI) character.
Inserts zero width joiner (ZWJ) character.
Inserts zero width non-joiner (ZWNJ) character.
Inserts word joiner (WJ) character.
Inserts soft hyphen (SHY) character.
Represents the size of the MenuItems enum.
KEYBOARD_TYPE_DEFAULT = 0
Default text virtual keyboard.
KEYBOARD_TYPE_MULTILINE = 1
Multiline virtual keyboard.
KEYBOARD_TYPE_NUMBER = 2
Virtual number keypad, useful for PIN entry.
KEYBOARD_TYPE_NUMBER_DECIMAL = 3
Virtual number keypad, useful for entering fractional numbers.
KEYBOARD_TYPE_PHONE = 4
Virtual phone number keypad.
KEYBOARD_TYPE_EMAIL_ADDRESS = 5
Virtual keyboard with additional keys to assist with typing email addresses.
KEYBOARD_TYPE_PASSWORD = 6
Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.
KEYBOARD_TYPE_URL = 7
Virtual keyboard with additional keys to assist with typing URLs.
Text alignment as defined in the HorizontalAlignment enum.
If true
, makes the caret blink.
The interval at which the caret blinks (in seconds).
The caret's column position inside the LineEdit. When set, the text may scroll to accommodate it.
If true
, the LineEdit will always show the caret, even if focus is lost.
Allow moving caret, selecting and removing the individual composite character components.
Note: Backspace is always removing individual composite character components.
If true
, the LineEdit will show a clear button if text is not empty, which can be used to clear the text quickly.
If true
, the context menu will appear when right-clicked.
If true
, the selected text will be deselected when focus is lost.
If true
, allow drag and drop of selected text.
If true
, control characters are displayed.
If false
, existing text cannot be modified and new text cannot be added.
If true
, the LineEdit width will increase to stay longer than the text. It will not compress if the text is shortened.
If true
, the LineEdit doesn't display decoration.
Language code used for line-breaking and text shaping algorithms. If left empty, current locale is used instead.
Maximum number of characters that can be entered inside the LineEdit. If 0
, there is no limit.
When a limit is defined, characters that would exceed max_length are truncated. This happens both for existing text contents when setting the max length, or for new text inserted in the LineEdit, including pasting. If any input text is truncated, the text_change_rejected signal is emitted with the truncated substring as parameter.
Example:
If false
, using middle mouse button to paste clipboard will be disabled.
Note: This method is only implemented on Linux.
Text shown when the LineEdit is empty. It is not the LineEdit's default value (see text).
Sets the icon that will appear in the right end of the LineEdit if there's no text, or always, if clear_button_enabled is set to false
.
If true
, every character is replaced with the secret character (see secret_character).
The character to use to mask secret input. Only a single character can be used as the secret character. If it is longer than one character, only the first one will be used. If it is empty, a space will be used instead.
If true
, the LineEdit will select the whole text when it gains focus.
If false
, it's impossible to select the text using mouse nor keyboard.
If false
, using shortcuts will be disabled.
Set BiDi algorithm override for the structured text.
Set additional options for BiDi override.
String value of the LineEdit.
Note: Changing text using this property won't emit the text_changed signal.
Base text writing direction.
If true
, the native virtual keyboard is shown when focused on platforms that support it.
Specifies the type of virtual keyboard to show.
Erases the LineEdit's text.
Deletes one character at the caret's current position (equivalent to pressing Delete).
Deletes a section of the text going from position from_column
to to_column
. Both parameters should be within the text's length.
Clears the current selection.
Returns the PopupMenu of this LineEdit. By default, this menu is displayed when right-clicking on the LineEdit.
You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see MenuItems). For example:
Warning: 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 Window.visible property.
Returns the scroll offset due to caret_column, as a number of characters.
Returns the text inside the selection.
Returns the selection begin column.
Returns the selection end column.
Returns true
if the user has selected text.
Inserts text
at the caret. If the resulting value is longer than max_length, nothing happens.
Returns whether the menu is visible. Use this instead of get_menu().visible
to improve performance (so the creation of the menu is avoided).
Executes a given action as defined in the MenuItems enum.
Selects characters inside LineEdit between from
and to
. By default, from
is at the beginning and to
at the end.
Selects the whole String.