Control that provides single-line string editing.
    public class LineEdit : Control

LineEdit provides a single-line string editor, used for text fields. It features many built-in shortcuts which will always be available:

  • 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

Inheritance Chain

Constructors

    public LineEdit()

Signals

    "text_changed" (String new_text)

Emitted when the text changes.

    "text_entered" (String new_text)

Emitted when the user presses [constant KEY_ENTER] on the LineEdit.

Properties

    public AlignEnum Align { get; set; }

Text alignment as defined in the ALIGN_* enum.

    public bool CaretBlink { get; set; }

If true, the caret (visual cursor) blinks.

    public float CaretBlinkSpeed { get; set; }

Duration (in seconds) of a caret’s blinking cycle.

    public int CaretPosition { get; set; }

The cursor’s position inside the LineEdit. When set, the text may scroll to accommodate it.

    public bool ClearButtonEnabled { get; set; }

If true, the LineEdit will show a clear button if text is not empty.

    public bool ContextMenuEnabled { get; set; }

If true, the context menu will appear when right-clicked.

    public bool Editable { get; set; }

If false, existing text cannot be modified and new text cannot be added.

    public bool ExpandToTextLength { get; set; }

If true, the LineEdit width will increase to stay longer than the Text. It will not compress if the Text is shortened.

    public int MaxLength { get; set; }

Maximum amount of characters that can be entered inside the LineEdit. If 0, there is no limit.

    public float PlaceholderAlpha { get; set; }

Opacity of the PlaceholderText. From 0 to 1.

    public string PlaceholderText { get; set; }

Text shown when the LineEdit is empty. It is not the LineEdit’s default value (see Text).

    public Texture RightIcon { get; set; }

Sets the icon that will appear in the right end of the LineEdit if there’s no Text, or always, if ClearButtonEnabled is set to false.

    public bool Secret { get; set; }

If true, every character is replaced with the secret character (see SecretCharacter).

    public string SecretCharacter { get; set; }

The character to use to mask secret input (defaults to “*”). Only a single character can be used as the secret character.

    public bool SelectingEnabled { get; set; }

    public bool ShortcutKeysEnabled { get; set; }

    public string Text { get; set; }

String value of the LineEdit.

Methods

    public void AppendAtCursor(string text)

Adds text after the cursor. If the resulting value is longer than MaxLength, nothing happens.

    public void Clear()

Erases the LineEdit text.

    [Obsolete("CursorGetBlinkEnabled is deprecated. Use the CaretBlink property instead.")]
    public bool CursorGetBlinkEnabled()

Getter for CaretBlink

    [Obsolete("CursorGetBlinkSpeed is deprecated. Use the CaretBlinkSpeed property instead.")]
    public float CursorGetBlinkSpeed()

Getter for CaretBlinkSpeed

    [Obsolete("CursorSetBlinkEnabled is deprecated. Use the CaretBlink property instead.")]
    public void CursorSetBlinkEnabled(bool enabled)

Setter for CaretBlink

    [Obsolete("CursorSetBlinkSpeed is deprecated. Use the CaretBlinkSpeed property instead.")]
    public void CursorSetBlinkSpeed(float blinkSpeed)

Setter for CaretBlinkSpeed

    public void Deselect()

Clears the current selection.

    [Obsolete("GetAlign is deprecated. Use the Align property instead.")]
    public AlignEnum GetAlign()

Getter for Align

    [Obsolete("GetCursorPosition is deprecated. Use the CaretPosition property instead.")]
    public int GetCursorPosition()

Getter for CaretPosition

    [Obsolete("GetExpandToTextLength is deprecated. Use the ExpandToTextLength property instead.")]
    public bool GetExpandToTextLength()

Getter for ExpandToTextLength

    [Obsolete("GetMaxLength is deprecated. Use the MaxLength property instead.")]
    public int GetMaxLength()

Getter for MaxLength

    public PopupMenu GetMenu()

Returns the PopupMenu of this LineEdit. By default, this menu is displayed when right-clicking on the LineEdit.

    [Obsolete("GetPlaceholder is deprecated. Use the PlaceholderText property instead.")]
    public string GetPlaceholder()

Getter for PlaceholderText

    [Obsolete("GetPlaceholderAlpha is deprecated. Use the PlaceholderAlpha property instead.")]
    public float GetPlaceholderAlpha()

Getter for PlaceholderAlpha

    [Obsolete("GetRightIcon is deprecated. Use the RightIcon property instead.")]
    public Texture GetRightIcon()

Getter for RightIcon

    [Obsolete("GetSecretCharacter is deprecated. Use the SecretCharacter property instead.")]
    public string GetSecretCharacter()

Getter for SecretCharacter

    [Obsolete("GetText is deprecated. Use the Text property instead.")]
    public string GetText()

Getter for Text

    [Obsolete("IsClearButtonEnabled is deprecated. Use the ClearButtonEnabled property instead.")]
    public bool IsClearButtonEnabled()

Getter for ClearButtonEnabled

    [Obsolete("IsContextMenuEnabled is deprecated. Use the ContextMenuEnabled property instead.")]
    public bool IsContextMenuEnabled()

Getter for ContextMenuEnabled

    [Obsolete("IsEditable is deprecated. Use the Editable property instead.")]
    public bool IsEditable()

Getter for Editable

    [Obsolete("IsSecret is deprecated. Use the Secret property instead.")]
    public bool IsSecret()

Getter for Secret

    [Obsolete("IsSelectingEnabled is deprecated. Use the SelectingEnabled property instead.")]
    public bool IsSelectingEnabled()

Getter for SelectingEnabled

    [Obsolete("IsShortcutKeysEnabled is deprecated. Use the ShortcutKeysEnabled property instead.")]
    public bool IsShortcutKeysEnabled()

Getter for ShortcutKeysEnabled

    public void MenuOption(int option)

Executes a given action as defined in theMENU_* enum.

    public void Select(int from = 0, int to = -1)

Selects characters inside LineEdit between from and to. By default, from is at the beginning and to at the end.

[codeblock]

text = “Welcome”

select() # Will select “Welcome”

select(4) # Will select “ome”

select(2, 5) # Will select “lco”

[/codeblock]

    public void SelectAll()

Selects the whole String.

    [Obsolete("SetAlign is deprecated. Use the Align property instead.")]
    public void SetAlign(AlignEnum align)

Setter for Align

    [Obsolete("SetClearButtonEnabled is deprecated. Use the ClearButtonEnabled property instead.")]
    public void SetClearButtonEnabled(bool enable)

Setter for ClearButtonEnabled

    [Obsolete("SetContextMenuEnabled is deprecated. Use the ContextMenuEnabled property instead.")]
    public void SetContextMenuEnabled(bool enable)

Setter for ContextMenuEnabled

    [Obsolete("SetCursorPosition is deprecated. Use the CaretPosition property instead.")]
    public void SetCursorPosition(int position)

Setter for CaretPosition

    [Obsolete("SetEditable is deprecated. Use the Editable property instead.")]
    public void SetEditable(bool enabled)

Setter for Editable

    [Obsolete("SetExpandToTextLength is deprecated. Use the ExpandToTextLength property instead.")]
    public void SetExpandToTextLength(bool enabled)

Setter for ExpandToTextLength

    [Obsolete("SetMaxLength is deprecated. Use the MaxLength property instead.")]
    public void SetMaxLength(int chars)

Setter for MaxLength

    [Obsolete("SetPlaceholder is deprecated. Use the PlaceholderText property instead.")]
    public void SetPlaceholder(string text)

Setter for PlaceholderText

    [Obsolete("SetPlaceholderAlpha is deprecated. Use the PlaceholderAlpha property instead.")]
    public void SetPlaceholderAlpha(float alpha)

Setter for PlaceholderAlpha

    [Obsolete("SetRightIcon is deprecated. Use the RightIcon property instead.")]
    public void SetRightIcon(Texture icon)

Setter for RightIcon

    [Obsolete("SetSecret is deprecated. Use the Secret property instead.")]
    public void SetSecret(bool enabled)

Setter for Secret

    [Obsolete("SetSecretCharacter is deprecated. Use the SecretCharacter property instead.")]
    public void SetSecretCharacter(string character)

Setter for SecretCharacter

    [Obsolete("SetSelectingEnabled is deprecated. Use the SelectingEnabled property instead.")]
    public void SetSelectingEnabled(bool enable)

Setter for SelectingEnabled

    [Obsolete("SetShortcutKeysEnabled is deprecated. Use the ShortcutKeysEnabled property instead.")]
    public void SetShortcutKeysEnabled(bool enable)

Setter for ShortcutKeysEnabled

    [Obsolete("SetText is deprecated. Use the Text property instead.")]
    public void SetText(string text)

Setter for Text

Inner Types

AlignEnum

Name Value Description
Left 0 Aligns the text on the left-hand side of the [LineEdit].
Center 1 Centers the text in the middle of the [LineEdit].
Right 2 Aligns the text on the right-hand side of the [LineEdit].
Fill 3 Stretches whitespaces to fit the [LineEdit]’s width.

Name Value Description
Cut 0 Cuts (copies and clears) the selected text.
Copy 1 Copies the selected text.
Paste 2 Pastes the clipboard text over the selected text (or at the cursor’s position).
Non-printable escape characters are automatically stripped from the OS clipboard via [method String.strip_escapes].    
Clear 3 Erases the whole [LineEdit] text.
SelectAll 4 Selects the whole [LineEdit] text.
Undo 5 Undoes the previous action.
Redo 6 Reverse the last undo action.
Max 7 Represents the size of the [enum MenuItems] enum.
Tags: