An input field for single-line text.
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.
While entering text, it is possible to insert special characters using Unicode, OEM or Windows alt codes:
- To enter Unicode codepoints, hold Alt and type the codepoint on the numpad. For example, to enter the character á (U+00E1), hold Alt and type +E1 on the numpad (the leading zeroes can be omitted).
- To enter OEM codepoints, hold Alt and type the code on the numpad. For example, to enter the character á (OEM 160), hold Alt and type 160 on the numpad.
- To enter Windows codepoints, hold Alt and type the code on the numpad. For example, to enter the character á (Windows 0225), hold Alt and type 0, 2, 2, 5 on the numpad. The leading zero here must not be omitted, as this is how Windows codepoints are distinguished from OEM codepoints.
Important:
- Focusing the LineEdit with ui_focus_next (by default Tab) or ui_focus_prev (by default Shift + Tab) or Control.grab_focus() still enters edit mode (for compatibility).
LineEdit 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
Note: Caret movement shortcuts listed above are not affected by shortcut_keys_enabled.
If true and caret_mid_grapheme is false, backspace deletes an entire composite character such as ❤️🩹, instead of deleting part of the composite character.
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 not editing or 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 not exit edit mode when text is submitted by pressing ui_text_submit action (by default: Enter or Kp Enter).
Language code used for line-breaking and text shaping algorithms. If left empty, the 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 a parameter:
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 a parameter.If false, using middle mouse button to paste clipboard will be disabled.
Note: This method is only implemented on Linux.
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.
Scale ratio of the icon when icon_expand_mode is set to EXPAND_MODE_FIT_TO_LINE_EDIT.
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.
String value of the LineEdit.
Note: Changing text using this property won't emit the text_changed signal.
Applies text from the Input Method Editor (IME) and closes the IME if it is open.
Closes the Input Method Editor (IME) if it is open. Any text in the IME will be lost.
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.
Allows entering edit mode whether the LineEdit is focused or not. If hide_focus is true, the focused state will not be shown (see Control.grab_focus()).
See also keep_editing_on_text_submit.
Returns the correct column at the end of a composite character like ❤️🩹 (mending heart; Unicode: U+2764 U+FE0F U+200D U+1FA79) which is comprised of more than one Unicode code point, if the caret is at the start of the composite character. Also returns the correct column with the caret at mid grapheme and for non-composite characters.
Note: To check at caret location use get_next_composite_character_column(get_caret_column())
Returns the correct column at the start of a composite character like ❤️🩹 (mending heart; Unicode: U+2764 U+FE0F U+200D U+1FA79) which is comprised of more than one Unicode code point, if the caret is at the end of the composite character. Also returns the correct column with the caret at mid grapheme and for non-composite characters.
Note: To check at caret location use get_previous_composite_character_column(get_caret_column())
Returns the scroll offset due to caret_column, as a number of characters.
Inserts text at the caret. If the resulting value is longer than max_length, nothing happens.
Selects characters inside LineEdit between from and to. By default, from is at the beginning and to at the end.
text = "Welcome"
select() # Will select "Welcome".
select(4) # Will select "ome".
select(2, 5) # Will select "lco".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 user presses the ui_text_submit action (by default: Enter or Kp Enter) while the LineEdit has focus.
MENU_CUT = 0Cuts (copies and clears) the selected text.
MENU_COPY = 1Copies the selected text.
MENU_PASTE = 2Pastes the clipboard text over the selected text (or at the caret's position).
Non-printable escape characters are automatically stripped from the OS clipboard via String.strip_escapes().
MENU_CLEAR = 3Erases the whole LineEdit text.
MENU_SELECT_ALL = 4Selects the whole LineEdit text.
MENU_UNDO = 5Undoes the previous action.
MENU_REDO = 6Reverse the last undo action.
MENU_SUBMENU_TEXT_DIR = 7ID of "Text Writing Direction" submenu.
MENU_DIR_INHERITED = 8Sets text direction to inherited.
MENU_DIR_AUTO = 9Sets text direction to automatic.
MENU_DIR_LTR = 10Sets text direction to left-to-right.
MENU_DIR_RTL = 11Sets text direction to right-to-left.
MENU_DISPLAY_UCC = 12Toggles control character display.
MENU_SUBMENU_INSERT_UCC = 13ID of "Insert Control Character" submenu.
MENU_INSERT_LRM = 14Inserts left-to-right mark (LRM) character.
MENU_INSERT_RLM = 15Inserts right-to-left mark (RLM) character.
MENU_INSERT_LRE = 16Inserts start of left-to-right embedding (LRE) character.
MENU_INSERT_RLE = 17Inserts start of right-to-left embedding (RLE) character.
MENU_INSERT_LRO = 18Inserts start of left-to-right override (LRO) character.
MENU_INSERT_RLO = 19Inserts start of right-to-left override (RLO) character.
MENU_INSERT_PDF = 20Inserts pop direction formatting (PDF) character.
MENU_INSERT_ALM = 21Inserts Arabic letter mark (ALM) character.
MENU_INSERT_LRI = 22Inserts left-to-right isolate (LRI) character.
MENU_INSERT_RLI = 23Inserts right-to-left isolate (RLI) character.
MENU_INSERT_FSI = 24Inserts first strong isolate (FSI) character.
MENU_INSERT_PDI = 25Inserts pop direction isolate (PDI) character.
MENU_INSERT_ZWJ = 26Inserts zero width joiner (ZWJ) character.
MENU_INSERT_ZWNJ = 27Inserts zero width non-joiner (ZWNJ) character.
MENU_INSERT_WJ = 28Inserts word joiner (WJ) character.
MENU_INSERT_SHY = 29Inserts soft hyphen (SHY) character.
MENU_EMOJI_AND_SYMBOL = 30Opens system emoji and symbol picker.
MENU_MAX = 31Represents the size of the MenuItems enum.
KEYBOARD_TYPE_DEFAULT = 0Default text virtual keyboard.
KEYBOARD_TYPE_MULTILINE = 1Multiline virtual keyboard.
KEYBOARD_TYPE_NUMBER = 2Virtual number keypad, useful for PIN entry.
KEYBOARD_TYPE_NUMBER_DECIMAL = 3Virtual number keypad, useful for entering fractional numbers.
KEYBOARD_TYPE_PHONE = 4Virtual phone number keypad.
KEYBOARD_TYPE_EMAIL_ADDRESS = 5Virtual keyboard with additional keys to assist with typing email addresses.
KEYBOARD_TYPE_PASSWORD = 6Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.
Note: This is not supported on Web. Instead, this behaves identically to KEYBOARD_TYPE_DEFAULT.
KEYBOARD_TYPE_URL = 7Virtual keyboard with additional keys to assist with typing URLs.