Files
godot-docs/classes/class_lineedit.rst
2017-11-13 09:27:07 +01:00

360 lines
19 KiB
ReStructuredText

.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the LineEdit.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_LineEdit:
LineEdit
========
**Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
**Category:** Core
Brief Description
-----------------
Control that provides single line string editing.
Member Functions
----------------
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`append_at_cursor<class_LineEdit_append_at_cursor>` **(** :ref:`String<class_string>` text **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`clear<class_LineEdit_clear>` **(** **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`cursor_get_blink_enabled<class_LineEdit_cursor_get_blink_enabled>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`cursor_get_blink_speed<class_LineEdit_cursor_get_blink_speed>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`cursor_set_blink_enabled<class_LineEdit_cursor_set_blink_enabled>` **(** :ref:`bool<class_bool>` enabled **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`cursor_set_blink_speed<class_LineEdit_cursor_set_blink_speed>` **(** :ref:`float<class_float>` blink_speed **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_align<class_LineEdit_get_align>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_cursor_position<class_LineEdit_get_cursor_position>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`get_expand_to_text_length<class_LineEdit_get_expand_to_text_length>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`get_max_length<class_LineEdit_get_max_length>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`PopupMenu<class_popupmenu>` | :ref:`get_menu<class_LineEdit_get_menu>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_string>` | :ref:`get_placeholder<class_LineEdit_get_placeholder>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`float<class_float>` | :ref:`get_placeholder_alpha<class_LineEdit_get_placeholder_alpha>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_string>` | :ref:`get_text<class_LineEdit_get_text>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_context_menu_enabled<class_LineEdit_is_context_menu_enabled>` **(** **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_editable<class_LineEdit_is_editable>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_secret<class_LineEdit_is_secret>` **(** **)** const |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`menu_option<class_LineEdit_menu_option>` **(** :ref:`int<class_int>` option **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`select<class_LineEdit_select>` **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`select_all<class_LineEdit_select_all>` **(** **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_align<class_LineEdit_set_align>` **(** :ref:`int<class_int>` align **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_context_menu_enabled<class_LineEdit_set_context_menu_enabled>` **(** :ref:`bool<class_bool>` enable **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_cursor_position<class_LineEdit_set_cursor_position>` **(** :ref:`int<class_int>` position **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_editable<class_LineEdit_set_editable>` **(** :ref:`bool<class_bool>` enabled **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_expand_to_text_length<class_LineEdit_set_expand_to_text_length>` **(** :ref:`bool<class_bool>` enabled **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_max_length<class_LineEdit_set_max_length>` **(** :ref:`int<class_int>` chars **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_placeholder<class_LineEdit_set_placeholder>` **(** :ref:`String<class_string>` text **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_placeholder_alpha<class_LineEdit_set_placeholder_alpha>` **(** :ref:`float<class_float>` alpha **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_secret<class_LineEdit_set_secret>` **(** :ref:`bool<class_bool>` enabled **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
| void | :ref:`set_text<class_LineEdit_set_text>` **(** :ref:`String<class_string>` text **)** |
+------------------------------------+------------------------------------------------------------------------------------------------------------------------+
Signals
-------
.. _class_LineEdit_text_changed:
- **text_changed** **(** :ref:`String<class_string>` text **)**
Emitted when the text changes.
.. _class_LineEdit_text_entered:
- **text_entered** **(** :ref:`String<class_string>` text **)**
Emitted when the user presses KEY_ENTER on the ``LineEdit``.
Member Variables
----------------
.. _class_LineEdit_align:
- :ref:`int<class_int>` **align** - Text alignment as defined in the ALIGN\_\* enum.
.. _class_LineEdit_caret_blink:
- :ref:`bool<class_bool>` **caret_blink** - If ``true`` the caret (visual cursor) blinks.
.. _class_LineEdit_caret_blink_speed:
- :ref:`float<class_float>` **caret_blink_speed** - Duration (in seconds) of a caret's blinking cycle.
.. _class_LineEdit_context_menu_enabled:
- :ref:`bool<class_bool>` **context_menu_enabled** - If ``true`` the context menu will appear when right clicked.
.. _class_LineEdit_editable:
- :ref:`bool<class_bool>` **editable** - If ``false`` existing text cannot be modified and new text cannot be added.
.. _class_LineEdit_expand_to_len:
- :ref:`bool<class_bool>` **expand_to_len** - If ``true`` the :ref:`LineEdit<class_lineedit>` width will increase to stay longer than the :ref:`text<class_LineEdit_text>`. It will **not** compress if the :ref:`text<class_LineEdit_text>` is shortened.
.. _class_LineEdit_focus_mode:
- :ref:`int<class_int>` **focus_mode** - Defines how the :ref:`LineEdit<class_lineedit>` can grab focus (Keyboard and mouse, only keyboard, or none). See ``enum FocusMode`` in :ref:`Control<class_control>` for details.
.. _class_LineEdit_max_length:
- :ref:`int<class_int>` **max_length** - Maximum amount of characters that can be entered inside the :ref:`LineEdit<class_lineedit>`. If ``0``, there is no limit.
.. _class_LineEdit_placeholder_alpha:
- :ref:`float<class_float>` **placeholder_alpha** - Opacity of the :ref:`placeholder_text<class_LineEdit_placeholder_text>`. From ``0`` to ``1``.
.. _class_LineEdit_placeholder_text:
- :ref:`String<class_string>` **placeholder_text** - Text shown when the :ref:`LineEdit<class_lineedit>` is empty. It is **not** the :ref:`LineEdit<class_lineedit>`'s default value (see :ref:`text<class_LineEdit_text>`).
.. _class_LineEdit_secret:
- :ref:`bool<class_bool>` **secret** - If ``true`` every character is shown as "\*".
.. _class_LineEdit_text:
- :ref:`String<class_string>` **text** - String value of the :ref:`LineEdit<class_lineedit>`.
Numeric Constants
-----------------
- **ALIGN_LEFT** = **0** --- Aligns the text on the left hand side of the :ref:`LineEdit<class_lineedit>`.
- **ALIGN_CENTER** = **1** --- Centers the text in the middle of the :ref:`LineEdit<class_lineedit>`.
- **ALIGN_RIGHT** = **2** --- Aligns the text on the right hand side of the :ref:`LineEdit<class_lineedit>`.
- **ALIGN_FILL** = **3** --- Stretches whitespaces to fit the :ref:`LineEdit<class_lineedit>`'s width.
- **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).
- **MENU_CLEAR** = **3** --- Erases the whole Linedit text.
- **MENU_SELECT_ALL** = **4** --- Selects the whole Linedit text.
- **MENU_UNDO** = **5** --- Undoes the previous action.
- **MENU_REDO** = **6**
- **MENU_MAX** = **7**
Description
-----------
LineEdit provides a single line string editor, used for text fields.
Member Function Description
---------------------------
.. _class_LineEdit_append_at_cursor:
- void **append_at_cursor** **(** :ref:`String<class_string>` text **)**
Adds ``text`` after the cursor. If the resulting value is longer than :ref:`max_length<class_LineEdit_max_length>`, nothing happens.
.. _class_LineEdit_clear:
- void **clear** **(** **)**
Erases the :ref:`LineEdit<class_lineedit>` text.
.. _class_LineEdit_cursor_get_blink_enabled:
- :ref:`bool<class_bool>` **cursor_get_blink_enabled** **(** **)** const
Gets whether the line edit caret is blinking.
.. _class_LineEdit_cursor_get_blink_speed:
- :ref:`float<class_float>` **cursor_get_blink_speed** **(** **)** const
Gets the line edit caret blink speed.
.. _class_LineEdit_cursor_set_blink_enabled:
- void **cursor_set_blink_enabled** **(** :ref:`bool<class_bool>` enabled **)**
Set the line edit caret to blink.
.. _class_LineEdit_cursor_set_blink_speed:
- void **cursor_set_blink_speed** **(** :ref:`float<class_float>` blink_speed **)**
Set the line edit caret blink speed. Cannot be less then or equal to 0.
.. _class_LineEdit_get_align:
- :ref:`int<class_int>` **get_align** **(** **)** const
Return the align mode of the ``LineEdit``.
.. _class_LineEdit_get_cursor_position:
- :ref:`int<class_int>` **get_cursor_position** **(** **)** const
Returns the cursor position inside the ``LineEdit``.
.. _class_LineEdit_get_expand_to_text_length:
- :ref:`bool<class_bool>` **get_expand_to_text_length** **(** **)** const
.. _class_LineEdit_get_max_length:
- :ref:`int<class_int>` **get_max_length** **(** **)** const
Return the maximum amount of characters the ``LineEdit`` can edit. If 0 is returned, no limit exists.
.. _class_LineEdit_get_menu:
- :ref:`PopupMenu<class_popupmenu>` **get_menu** **(** **)** const
Returns the :ref:`PopupMenu<class_popupmenu>` of this ``LineEdit``. By default, this menu is displayed when right-clicking on the :ref:`LineEdit<class_lineedit>`.
.. _class_LineEdit_get_placeholder:
- :ref:`String<class_string>` **get_placeholder** **(** **)** const
Return the placeholder text.
.. _class_LineEdit_get_placeholder_alpha:
- :ref:`float<class_float>` **get_placeholder_alpha** **(** **)** const
Return transparency of the placeholder text.
.. _class_LineEdit_get_text:
- :ref:`String<class_string>` **get_text** **(** **)** const
Return the text in the ``LineEdit``.
.. _class_LineEdit_is_context_menu_enabled:
- :ref:`bool<class_bool>` **is_context_menu_enabled** **(** **)**
Returns true if the context menu is enabled.
.. _class_LineEdit_is_editable:
- :ref:`bool<class_bool>` **is_editable** **(** **)** const
Return the *editable* status of the ``LineEdit`` (see :ref:`set_editable<class_LineEdit_set_editable>`).
.. _class_LineEdit_is_secret:
- :ref:`bool<class_bool>` **is_secret** **(** **)** const
Return the *secret* status of the ``LineEdit`` (see :ref:`set_secret<class_LineEdit_set_secret>`).
.. _class_LineEdit_menu_option:
- void **menu_option** **(** :ref:`int<class_int>` option **)**
Executes a given action as defined in the MENU\_\* enum.
.. _class_LineEdit_select:
- void **select** **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)**
Selects characters inside :ref:`LineEdit<class_lineedit>` between ``from`` and ``to``. By default ``from`` is at the beginning and ``to`` at the end.
::
text = "Welcome"
select() # Welcome
select(4) # ome
select(2, 5) # lco
.. _class_LineEdit_select_all:
- void **select_all** **(** **)**
Selects the whole :ref:`String<class_string>`.
.. _class_LineEdit_set_align:
- void **set_align** **(** :ref:`int<class_int>` align **)**
Set text alignment of the ``LineEdit``.
.. _class_LineEdit_set_context_menu_enabled:
- void **set_context_menu_enabled** **(** :ref:`bool<class_bool>` enable **)**
Set the status of the context menu. When enabled, the context menu will appear when the ``LineEdit`` is right clicked.
.. _class_LineEdit_set_cursor_position:
- void **set_cursor_position** **(** :ref:`int<class_int>` position **)**
Sets the cursor position inside the ``LineEdit``. The text may scroll if needed.
.. _class_LineEdit_set_editable:
- void **set_editable** **(** :ref:`bool<class_bool>` enabled **)**
Set the *editable* status of the ``LineEdit``. When disabled, existing text can't be modified and new text can't be added.
.. _class_LineEdit_set_expand_to_text_length:
- void **set_expand_to_text_length** **(** :ref:`bool<class_bool>` enabled **)**
.. _class_LineEdit_set_max_length:
- void **set_max_length** **(** :ref:`int<class_int>` chars **)**
Set the maximum amount of characters the ``LineEdit`` can edit, and cropping existing text in case it exceeds that limit. Setting 0 removes the limit.
.. _class_LineEdit_set_placeholder:
- void **set_placeholder** **(** :ref:`String<class_string>` text **)**
Set the placeholder text.
.. _class_LineEdit_set_placeholder_alpha:
- void **set_placeholder_alpha** **(** :ref:`float<class_float>` alpha **)**
Set transparency of the placeholder text.
.. _class_LineEdit_set_secret:
- void **set_secret** **(** :ref:`bool<class_bool>` enabled **)**
Set the *secret* status of the ``LineEdit``. When enabled, every character is displayed as "\*".
.. _class_LineEdit_set_text:
- void **set_text** **(** :ref:`String<class_string>` text **)**
Set the text in the ``LineEdit``, clearing the existing one and the selection.