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 or press the [code]ui_text_submit[/code] action (by default [kbd]Enter[/kbd] or [kbd]Kp Enter[/kbd]). - To exit edit mode, press [code]ui_text_submit[/code] or [code]ui_cancel[/code] (by default [kbd]Escape[/kbd]) actions. - Check [method edit], [method unedit], [method is_editing], and [signal editing_toggled] for more information. [b]Important:[/b] - Focusing the [LineEdit] with [code]ui_focus_next[/code] (by default [kbd]Tab[/kbd]) or [code]ui_focus_prev[/code] (by default [kbd]Shift + Tab[/kbd]) or [method Control.grab_focus] still enters edit mode (for compatibility). [LineEdit] features many built-in shortcuts that are always available ([kbd]Ctrl[/kbd] here maps to [kbd]Cmd[/kbd] on macOS): - [kbd]Ctrl + C[/kbd]: Copy - [kbd]Ctrl + X[/kbd]: Cut - [kbd]Ctrl + V[/kbd] or [kbd]Ctrl + Y[/kbd]: Paste/"yank" - [kbd]Ctrl + Z[/kbd]: Undo - [kbd]Ctrl + ~[/kbd]: Swap input direction. - [kbd]Ctrl + Shift + Z[/kbd]: Redo - [kbd]Ctrl + U[/kbd]: Delete text from the caret position to the beginning of the line - [kbd]Ctrl + K[/kbd]: Delete text from the caret position to the end of the line - [kbd]Ctrl + A[/kbd]: Select all text - [kbd]Up Arrow[/kbd]/[kbd]Down Arrow[/kbd]: Move the caret to the beginning/end of the line On macOS, some extra keyboard shortcuts are available: - [kbd]Cmd + F[/kbd]: Same as [kbd]Right Arrow[/kbd], move the caret one character right - [kbd]Cmd + B[/kbd]: Same as [kbd]Left Arrow[/kbd], move the caret one character left - [kbd]Cmd + P[/kbd]: Same as [kbd]Up Arrow[/kbd], move the caret to the previous line - [kbd]Cmd + N[/kbd]: Same as [kbd]Down Arrow[/kbd], move the caret to the next line - [kbd]Cmd + D[/kbd]: Same as [kbd]Delete[/kbd], delete the character on the right side of caret - [kbd]Cmd + H[/kbd]: Same as [kbd]Backspace[/kbd], delete the character on the left side of the caret - [kbd]Cmd + A[/kbd]: Same as [kbd]Home[/kbd], move the caret to the beginning of the line - [kbd]Cmd + E[/kbd]: Same as [kbd]End[/kbd], move the caret to the end of the line - [kbd]Cmd + Left Arrow[/kbd]: Same as [kbd]Home[/kbd], move the caret to the beginning of the line - [kbd]Cmd + Right Arrow[/kbd]: Same as [kbd]End[/kbd], move the caret to the end of the line [b]Note:[/b] Caret movement shortcuts listed above are not affected by [member shortcut_keys_enabled]. Applies text from the [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url] (IME) and closes the IME if it is open. Closes the [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url] (IME) if it is open. Any text in the IME will be lost. Erases the [LineEdit]'s [member text]. Deletes one character at the caret's current position (equivalent to pressing [kbd]Delete[/kbd]). Deletes a section of the [member text] going from position [param from_column] to [param to_column]. Both parameters should be within the text's length. Clears the current selection. Allows entering edit mode whether the [LineEdit] is focused or not. Use [method Callable.call_deferred] if you want to enter edit mode on [signal text_submitted]. 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 [enum MenuItems]). For example: [codeblocks] [gdscript] func _ready(): var menu = get_menu() # Remove all items after "Redo". menu.item_count = menu.get_item_index(MENU_REDO) + 1 # Add custom items. menu.add_separator() menu.add_item("Insert Date", MENU_MAX + 1) # Connect callback. menu.id_pressed.connect(_on_item_pressed) func _on_item_pressed(id): if id == MENU_MAX + 1: insert_text_at_caret(Time.get_date_string_from_system()) [/gdscript] [csharp] public override void _Ready() { var menu = GetMenu(); // Remove all items after "Redo". menu.ItemCount = menu.GetItemIndex(LineEdit.MenuItems.Redo) + 1; // Add custom items. menu.AddSeparator(); menu.AddItem("Insert Date", LineEdit.MenuItems.Max + 1); // Add event handler. menu.IdPressed += OnItemPressed; } public void OnItemPressed(int id) { if (id == LineEdit.MenuItems.Max + 1) { InsertTextAtCaret(Time.GetDateStringFromSystem()); } } [/csharp] [/codeblocks] [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 Window.visible] property. Returns the scroll offset due to [member caret_column], as a number of characters. Returns the text inside the selection. Returns the selection begin column. Returns the selection end column. Returns [code]true[/code] if the user has text in the [url=https://en.wikipedia.org/wiki/Input_method]Input Method Editor[/url] (IME). Returns [code]true[/code] if a "redo" action is available. Returns [code]true[/code] if the user has selected text. Returns [code]true[/code] if an "undo" action is available. Inserts [param text] at the caret. If the resulting value is longer than [member max_length], nothing happens. Returns whether the [LineEdit] is being edited. Returns whether the menu is visible. Use this instead of [code]get_menu().visible[/code] to improve performance (so the creation of the menu is avoided). Executes a given action as defined in the [enum MenuItems] enum. Selects characters inside [LineEdit] between [param from] and [param to]. By default, [param from] is at the beginning and [param to] at the end. [codeblocks] [gdscript] text = "Welcome" select() # Will select "Welcome". select(4) # Will select "ome". select(2, 5) # Will select "lco". [/gdscript] [csharp] Text = "Welcome"; Select(); // Will select "Welcome". Select(4); // Will select "ome". Select(2, 5); // Will select "lco". [/csharp] [/codeblocks] Selects the whole [String]. Allows exiting edit mode while preserving focus. Text alignment as defined in the [enum HorizontalAlignment] enum. If [code]true[/code], 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 [code]true[/code], the [LineEdit] will always show the caret, even if focus is lost. Allow moving caret, selecting and removing the individual composite character components. [b]Note:[/b] [kbd]Backspace[/kbd] is always removing individual composite character components. If [code]true[/code], the [LineEdit] will show a clear button if [member text] is not empty, which can be used to clear the text quickly. If [code]true[/code], the context menu will appear when right-clicked. If [code]true[/code], the selected text will be deselected when focus is lost. If [code]true[/code], allow drag and drop of selected text. If [code]true[/code], control characters are displayed. If [code]false[/code], existing text cannot be modified and new text cannot be added. 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. If [code]true[/code], 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 [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: [codeblocks] [gdscript] 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. [/gdscript] [csharp] Text = "Hello world"; MaxLength = 5; // `Text` becomes "Hello". MaxLength = 10; Text += " goodbye"; // `Text` becomes "Hello good". // `text_change_rejected` is emitted with "bye" as parameter. [/csharp] [/codeblocks] If [code]false[/code], using middle mouse button to paste clipboard will be disabled. [b]Note:[/b] This method is only implemented on Linux. Text shown when the [LineEdit] is empty. It is [b]not[/b] the [LineEdit]'s default value (see [member text]). 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]. If [code]true[/code], every character is replaced with the secret character (see [member 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 [code]true[/code], the [LineEdit] will select the whole text when it gains focus. If [code]false[/code], it's impossible to select the text using mouse nor keyboard. If [code]true[/code], shortcut keys for context menu items are enabled, even if the context menu is disabled. Set BiDi algorithm override for the structured text. Set additional options for BiDi override. String value of the [LineEdit]. [b]Note:[/b] Changing text using this property won't emit the [signal text_changed] signal. Base text writing direction. If [code]true[/code], the native virtual keyboard is shown when focused on platforms that support it. Specifies the type of virtual keyboard to show. Emitted when the [LineEdit] switches in or out of edit mode. 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 [param rejected_substring] argument. Emitted when the text changes. Emitted when the user presses the [code]ui_text_submit[/code] action (by default: [kbd]Enter[/kbd] or [kbd]Kp Enter[/kbd]) while the [LineEdit] has focus. 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). Non-printable escape characters are automatically stripped from the OS clipboard via [method String.strip_escapes]. 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 [enum MenuItems] enum. Default text virtual keyboard. Multiline virtual keyboard. Virtual number keypad, useful for PIN entry. Virtual number keypad, useful for entering fractional numbers. Virtual phone number keypad. Virtual keyboard with additional keys to assist with typing email addresses. Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization. [b]Note:[/b] This is not supported on Web. Instead, this behaves identically to [constant KEYBOARD_TYPE_DEFAULT]. Virtual keyboard with additional keys to assist with typing URLs. Color of the [LineEdit]'s caret (text cursor). This can be set to a fully transparent color to hide the caret entirely. Color used as default tint for the clear button. Color used for the clear button when it's pressed. Default font color. The tint of text outline of the [LineEdit]. Font color for [member placeholder_text]. Font color for selected text (inside the selection rectangle). Font color when editing is disabled. Color of the selection rectangle. The caret's width in pixels. Greater values can be used to improve accessibility by ensuring the caret is easily visible, or to ensure consistency with a large font size. Minimum horizontal space for the text (not counting the clear button and content margins). This value is measured in count of 'M' characters (i.e. this number of 'M' characters can be displayed without scrolling). The size of the text outline. [b]Note:[/b] If using a font with [member FontFile.multichannel_signed_distance_field] enabled, its [member FontFile.msdf_pixel_range] must be set to at least [i]twice[/i] the value of [theme_item outline_size] for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended. Font used for the text. Font size of the [LineEdit]'s text. Texture for the clear button. See [member clear_button_enabled]. Background used when [LineEdit] has GUI focus. The [theme_item focus] [StyleBox] is displayed [i]over[/i] the base [StyleBox], so a partially transparent [StyleBox] should be used to ensure the base [StyleBox] remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons. Default background for the [LineEdit]. Background used when [LineEdit] is in read-only mode ([member editable] is set to [code]false[/code]).