:github_url: hide

.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the TLLineEdit.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.

.. _class_TLLineEdit:

TLLineEdit
==========

**Inherits:** 

**Category:** Core

Brief Description
-----------------

Control that provides single-line string editing. For formatted or/and multiline text, use :ref:`TLRichTextEdit<class_TLRichTextEdit>`.

Copy of Godot LineEdit with the shaping support. TLLineEdit uses the same theme items as the LineEdit.

Properties
----------

+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| int                                     | :ref:`align<class_TLLineEdit_property_align>`                                 | 0         |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| :ref:`TLFontFamily<class_TLFontFamily>` | :ref:`base_font<class_TLLineEdit_property_base_font>`                         |           |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| int                                     | :ref:`base_font_size<class_TLLineEdit_property_base_font_size>`               | 12        |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| String                                  | :ref:`base_font_style<class_TLLineEdit_property_base_font_style>`             | "Regular" |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`caret_blink<class_TLLineEdit_property_caret_blink>`                     | false     |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| float                                   | :ref:`caret_blink_speed<class_TLLineEdit_property_caret_blink_speed>`         | 0.65      |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| int                                     | :ref:`caret_position<class_TLLineEdit_property_caret_position>`               | 0         |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`clear_button_enabled<class_TLLineEdit_property_clear_button_enabled>`   | false     |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`context_menu_enabled<class_TLLineEdit_property_context_menu_enabled>`   | true      |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`editable<class_TLLineEdit_property_editable>`                           | true      |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`expand_to_text_length<class_TLLineEdit_property_expand_to_text_length>` | false     |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| int                                     | focus_mode                                                                    | **O:** 2  |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| String                                  | :ref:`language<class_TLLineEdit_property_language>`                           | ""        |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| int                                     | :ref:`max_length<class_TLLineEdit_property_max_length>`                       | 0         |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| Control.CursorShape                     | mouse_default_cursor_shape                                                    | **O:** 1  |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| String                                  | :ref:`ot_features<class_TLLineEdit_property_ot_features>`                     | ""        |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| float                                   | :ref:`placeholder_alpha<class_TLLineEdit_property_placeholder_alpha>`         | 0.6       |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| String                                  | :ref:`placeholder_text<class_TLLineEdit_property_placeholder_text>`           | ""        |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| bool                                    | :ref:`secret<class_TLLineEdit_property_secret>`                               | false     |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| String                                  | :ref:`secret_character<class_TLLineEdit_property_secret_character>`           | "*"       |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| String                                  | :ref:`text<class_TLLineEdit_property_text>`                                   | ""        |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+
| int                                     | :ref:`text_direction<class_TLLineEdit_property_text_direction>`               | 3         |
+-----------------------------------------+-------------------------------------------------------------------------------+-----------+

Methods
-------

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-------------------------------------------------------------------------------------------+
   | void      | :ref:`append_at_cursor<class_TLLineEdit_method_append_at_cursor>` **(** String text **)** |
   +-----------+-------------------------------------------------------------------------------------------+
   | void      | :ref:`clear<class_TLLineEdit_method_clear>` **(** **)**                                   |
   +-----------+-------------------------------------------------------------------------------------------+
   | void      | :ref:`deselect<class_TLLineEdit_method_deselect>` **(** **)**                             |
   +-----------+-------------------------------------------------------------------------------------------+
   | PopupMenu | :ref:`get_menu<class_TLLineEdit_method_get_menu>` **(** **)** const                       |
   +-----------+-------------------------------------------------------------------------------------------+
   | void      | :ref:`menu_option<class_TLLineEdit_method_menu_option>` **(** int option **)**            |
   +-----------+-------------------------------------------------------------------------------------------+
   | void      | :ref:`select<class_TLLineEdit_method_select>` **(** int from=0, int to=-1 **)**           |
   +-----------+-------------------------------------------------------------------------------------------+
   | void      | :ref:`select_all<class_TLLineEdit_method_select_all>` **(** **)**                         |
   +-----------+-------------------------------------------------------------------------------------------+

Signals
-------

.. _class_TLLineEdit_signal_text_changed:

- **text_changed** **(** String new_text **)**

Emitted when the text changes.

----

.. _class_TLLineEdit_signal_text_entered:

- **text_entered** **(** String new_text **)**

Emitted when the user presses ``KEY_ENTER`` on the ``TLLineEdit``.

Enumerations
------------

.. _enum_TLLineEdit_Align:

.. _class_TLLineEdit_constant_ALIGN_LEFT:

.. _class_TLLineEdit_constant_ALIGN_CENTER:

.. _class_TLLineEdit_constant_ALIGN_RIGHT:

.. _class_TLLineEdit_constant_ALIGN_FILL:

enum **Align**:

- **ALIGN_LEFT** = **0** --- Aligns the text on the left-hand side of the ``TLLineEdit``.

- **ALIGN_CENTER** = **1** --- Centers the text in the middle of the ``TLLineEdit``.

- **ALIGN_RIGHT** = **2** --- Aligns the text on the right-hand side of the ``TLLineEdit``.

- **ALIGN_FILL** = **3** --- Stretches white spaces to fit the ``TLLineEdit``'s width.

----

.. _enum_TLLineEdit_MenuItems:

.. _class_TLLineEdit_constant_MENU_CUT:

.. _class_TLLineEdit_constant_MENU_COPY:

.. _class_TLLineEdit_constant_MENU_PASTE:

.. _class_TLLineEdit_constant_MENU_CLEAR:

.. _class_TLLineEdit_constant_MENU_SELECT_ALL:

.. _class_TLLineEdit_constant_MENU_UNDO:

.. _class_TLLineEdit_constant_MENU_REDO:

.. _class_TLLineEdit_constant_MENU_MAX:

enum **MenuItems**:

- **MENU_CUT** = **0** --- Cuts (copies and clears) the selected text.

- **MENU_COPY** = **1** --- Copies the selected text.

- **MENU_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 ``String.strip_escapes``.

- **MENU_CLEAR** = **3** --- Erases the whole ``TLLineEdit`` text.

- **MENU_SELECT_ALL** = **4** --- Selects the whole ``TLLineEdit`` text.

- **MENU_UNDO** = **5** --- Undoes the previous action.

- **MENU_REDO** = **6** --- Reverse the last undo action.

- **MENU_MAX** = **7** --- Represents the size of the :ref:`MenuItems<enum_TLLineEdit_MenuItems>` enum.

Description
-----------

TLLineEdit 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

- Ctrl + D: Swap current input direction (primary cursor)

- Up/Down arrow: Move the cursor to the beginning/end of the line

Property Descriptions
---------------------

.. _class_TLLineEdit_property_align:

- int **align**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+------------------+
   | *Default* | 0                |
   +-----------+------------------+
   | *Setter*  | set_align(value) |
   +-----------+------------------+
   | *Getter*  | get_align()      |
   +-----------+------------------+

Text alignment as defined in the ``ALIGN_*`` enum.

----

.. _class_TLLineEdit_property_base_font:

- :ref:`TLFontFamily<class_TLFontFamily>` **base_font**

.. table::
   :class: longtable
   :widths: 7 20

   +----------+----------------------+
   | *Setter* | set_base_font(value) |
   +----------+----------------------+
   | *Getter* | get_base_font()      |
   +----------+----------------------+

Base font.

----

.. _class_TLLineEdit_property_base_font_size:

- int **base_font_size**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------+
   | *Default* | 12                        |
   +-----------+---------------------------+
   | *Setter*  | set_base_font_size(value) |
   +-----------+---------------------------+
   | *Getter*  | get_base_font_size()      |
   +-----------+---------------------------+

Base font size.

----

.. _class_TLLineEdit_property_base_font_style:

- String **base_font_style**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+----------------------------+
   | *Default* | "Regular"                  |
   +-----------+----------------------------+
   | *Setter*  | set_base_font_style(value) |
   +-----------+----------------------------+
   | *Getter*  | get_base_font_style()      |
   +-----------+----------------------------+

Base font style.

----

.. _class_TLLineEdit_property_caret_blink:

- bool **caret_blink**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------------+
   | *Default* | false                           |
   +-----------+---------------------------------+
   | *Setter*  | cursor_set_blink_enabled(value) |
   +-----------+---------------------------------+
   | *Getter*  | cursor_get_blink_enabled()      |
   +-----------+---------------------------------+

If ``true``, the caret (visual cursor) blinks.

----

.. _class_TLLineEdit_property_caret_blink_speed:

- float **caret_blink_speed**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-------------------------------+
   | *Default* | 0.65                          |
   +-----------+-------------------------------+
   | *Setter*  | cursor_set_blink_speed(value) |
   +-----------+-------------------------------+
   | *Getter*  | cursor_get_blink_speed()      |
   +-----------+-------------------------------+

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

----

.. _class_TLLineEdit_property_caret_position:

- int **caret_position**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+----------------------------+
   | *Default* | 0                          |
   +-----------+----------------------------+
   | *Setter*  | set_cursor_position(value) |
   +-----------+----------------------------+
   | *Getter*  | get_cursor_position()      |
   +-----------+----------------------------+

The cursor's position inside the ``TLLineEdit``. When set, the text may scroll to accommodate it.

----

.. _class_TLLineEdit_property_clear_button_enabled:

- bool **clear_button_enabled**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------------+
   | *Default* | false                           |
   +-----------+---------------------------------+
   | *Setter*  | set_clear_button_enabled(value) |
   +-----------+---------------------------------+
   | *Getter*  | is_clear_button_enabled()       |
   +-----------+---------------------------------+

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

----

.. _class_TLLineEdit_property_context_menu_enabled:

- bool **context_menu_enabled**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------------+
   | *Default* | true                            |
   +-----------+---------------------------------+
   | *Setter*  | set_context_menu_enabled(value) |
   +-----------+---------------------------------+
   | *Getter*  | is_context_menu_enabled()       |
   +-----------+---------------------------------+

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

----

.. _class_TLLineEdit_property_editable:

- bool **editable**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------+
   | *Default* | true                |
   +-----------+---------------------+
   | *Setter*  | set_editable(value) |
   +-----------+---------------------+
   | *Getter*  | is_editable()       |
   +-----------+---------------------+

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

----

.. _class_TLLineEdit_property_expand_to_text_length:

- bool **expand_to_text_length**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+----------------------------------+
   | *Default* | false                            |
   +-----------+----------------------------------+
   | *Setter*  | set_expand_to_text_length(value) |
   +-----------+----------------------------------+
   | *Getter*  | get_expand_to_text_length()      |
   +-----------+----------------------------------+

If ``true``, the ``TLLineEdit`` width will increase to stay longer than the :ref:`text<class_TLLineEdit_property_text>`. It will **not** compress if the :ref:`text<class_TLLineEdit_property_text>` is shortened.

----

.. _class_TLLineEdit_property_language:

- String **language**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------+
   | *Default* | ""                  |
   +-----------+---------------------+
   | *Setter*  | set_language(value) |
   +-----------+---------------------+
   | *Getter*  | get_language()      |
   +-----------+---------------------+

Language code for line-breaking and text shaping algorithms.

----

.. _class_TLLineEdit_property_max_length:

- int **max_length**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-----------------------+
   | *Default* | 0                     |
   +-----------+-----------------------+
   | *Setter*  | set_max_length(value) |
   +-----------+-----------------------+
   | *Getter*  | get_max_length()      |
   +-----------+-----------------------+

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

----

.. _class_TLLineEdit_property_ot_features:

- String **ot_features**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+------------------------+
   | *Default* | ""                     |
   +-----------+------------------------+
   | *Setter*  | set_ot_features(value) |
   +-----------+------------------------+
   | *Getter*  | get_ot_features()      |
   +-----------+------------------------+

Comma separated list of OpenType feature tags.

----

.. _class_TLLineEdit_property_placeholder_alpha:

- float **placeholder_alpha**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+------------------------------+
   | *Default* | 0.6                          |
   +-----------+------------------------------+
   | *Setter*  | set_placeholder_alpha(value) |
   +-----------+------------------------------+
   | *Getter*  | get_placeholder_alpha()      |
   +-----------+------------------------------+

Opacity of the :ref:`placeholder_text<class_TLLineEdit_property_placeholder_text>`. From ``0`` to ``1``.

----

.. _class_TLLineEdit_property_placeholder_text:

- String **placeholder_text**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+------------------------+
   | *Default* | ""                     |
   +-----------+------------------------+
   | *Setter*  | set_placeholder(value) |
   +-----------+------------------------+
   | *Getter*  | get_placeholder()      |
   +-----------+------------------------+

Text shown when the ``TLLineEdit`` is empty. It is **not** the ``TLLineEdit``'s default value (see :ref:`text<class_TLLineEdit_property_text>`).

----

.. _class_TLLineEdit_property_secret:

- bool **secret**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-------------------+
   | *Default* | false             |
   +-----------+-------------------+
   | *Setter*  | set_secret(value) |
   +-----------+-------------------+
   | *Getter*  | is_secret()       |
   +-----------+-------------------+

If ``true``, every character is replaced with the secret character (see :ref:`secret_character<class_TLLineEdit_property_secret_character>`).

----

.. _class_TLLineEdit_property_secret_character:

- String **secret_character**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-----------------------------+
   | *Default* | "*"                         |
   +-----------+-----------------------------+
   | *Setter*  | set_secret_character(value) |
   +-----------+-----------------------------+
   | *Getter*  | get_secret_character()      |
   +-----------+-----------------------------+

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

----

.. _class_TLLineEdit_property_text:

- String **text**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+-----------------+
   | *Default* | ""              |
   +-----------+-----------------+
   | *Setter*  | set_text(value) |
   +-----------+-----------------+
   | *Getter*  | get_text()      |
   +-----------+-----------------+

String value of the ``TLLineEdit``.

----

.. _class_TLLineEdit_property_text_direction:

- int **text_direction**

.. table::
   :class: longtable
   :widths: 7 20

   +-----------+---------------------------+
   | *Default* | 3                         |
   +-----------+---------------------------+
   | *Setter*  | set_text_direction(value) |
   +-----------+---------------------------+
   | *Getter*  | get_text_direction()      |
   +-----------+---------------------------+

Base direction of the text.

Method Descriptions
-------------------

.. _class_TLLineEdit_method_append_at_cursor:

- void **append_at_cursor** **(** String text **)**

Adds ``text`` after the cursor. If the resulting value is longer than :ref:`max_length<class_TLLineEdit_property_max_length>`, nothing happens.

----

.. _class_TLLineEdit_method_clear:

- void **clear** **(** **)**

Erases the ``TLLineEdit`` text.

----

.. _class_TLLineEdit_method_deselect:

- void **deselect** **(** **)**

Clears the current selection.

----

.. _class_TLLineEdit_method_get_menu:

- PopupMenu **get_menu** **(** **)** const

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

----

.. _class_TLLineEdit_method_menu_option:

- void **menu_option** **(** int option **)**

Executes a given action as defined in the``MENU_*`` enum.

----

.. _class_TLLineEdit_method_select:

- void **select** **(** int from=0, int to=-1 **)**

Selects characters inside ``TLLineEdit`` 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"

----

.. _class_TLLineEdit_method_select_all:

- void **select_all** **(** **)**

Selects the whole String.

