class_lineedit.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the LineEdit.xml source instead.
  3. .. The source is found in doc/classes or modules/<name>/doc_classes.
  4. .. _class_LineEdit:
  5. LineEdit
  6. ========
  7. **Inherits:** :ref:`Control<class_control>` **<** :ref:`CanvasItem<class_canvasitem>` **<** :ref:`Node<class_node>` **<** :ref:`Object<class_object>`
  8. **Category:** Core
  9. Brief Description
  10. -----------------
  11. Control that provides single line string editing.
  12. Member Functions
  13. ----------------
  14. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  15. | void | :ref:`append_at_cursor<class_LineEdit_append_at_cursor>` **(** :ref:`String<class_string>` text **)** |
  16. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  17. | void | :ref:`clear<class_LineEdit_clear>` **(** **)** |
  18. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  19. | void | :ref:`deselect<class_LineEdit_deselect>` **(** **)** |
  20. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  21. | :ref:`PopupMenu<class_popupmenu>` | :ref:`get_menu<class_LineEdit_get_menu>` **(** **)** const |
  22. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  23. | void | :ref:`menu_option<class_LineEdit_menu_option>` **(** :ref:`int<class_int>` option **)** |
  24. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  25. | void | :ref:`select<class_LineEdit_select>` **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)** |
  26. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  27. | void | :ref:`select_all<class_LineEdit_select_all>` **(** **)** |
  28. +------------------------------------+------------------------------------------------------------------------------------------------------------+
  29. Signals
  30. -------
  31. .. _class_LineEdit_text_changed:
  32. - **text_changed** **(** :ref:`String<class_string>` new_text **)**
  33. Emitted when the text changes.
  34. .. _class_LineEdit_text_entered:
  35. - **text_entered** **(** :ref:`String<class_string>` new_text **)**
  36. Emitted when the user presses KEY_ENTER on the ``LineEdit``.
  37. Member Variables
  38. ----------------
  39. .. _class_LineEdit_align:
  40. - :ref:`Align<enum_lineedit_align>` **align** - Text alignment as defined in the ALIGN\_\* enum.
  41. .. _class_LineEdit_caret_blink:
  42. - :ref:`bool<class_bool>` **caret_blink** - If ``true`` the caret (visual cursor) blinks.
  43. .. _class_LineEdit_caret_blink_speed:
  44. - :ref:`float<class_float>` **caret_blink_speed** - Duration (in seconds) of a caret's blinking cycle.
  45. .. _class_LineEdit_caret_position:
  46. - :ref:`int<class_int>` **caret_position** - The cursor's position inside the ``LineEdit``. When set, the text may scroll to accommodate it.
  47. .. _class_LineEdit_context_menu_enabled:
  48. - :ref:`bool<class_bool>` **context_menu_enabled** - If ``true`` the context menu will appear when right clicked.
  49. .. _class_LineEdit_editable:
  50. - :ref:`bool<class_bool>` **editable** - If ``false`` existing text cannot be modified and new text cannot be added.
  51. .. _class_LineEdit_expand_to_text_length:
  52. - :ref:`bool<class_bool>` **expand_to_text_length** - 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.
  53. .. _class_LineEdit_focus_mode:
  54. - :ref:`FocusMode<enum_control_focusmode>` **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.
  55. .. _class_LineEdit_max_length:
  56. - :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.
  57. .. _class_LineEdit_placeholder_alpha:
  58. - :ref:`float<class_float>` **placeholder_alpha** - Opacity of the :ref:`placeholder_text<class_LineEdit_placeholder_text>`. From ``0`` to ``1``.
  59. .. _class_LineEdit_placeholder_text:
  60. - :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>`).
  61. .. _class_LineEdit_secret:
  62. - :ref:`bool<class_bool>` **secret** - If ``true`` every character is shown as "\*".
  63. .. _class_LineEdit_text:
  64. - :ref:`String<class_string>` **text** - String value of the :ref:`LineEdit<class_lineedit>`.
  65. Enums
  66. -----
  67. .. _enum_LineEdit_Align:
  68. enum **Align**
  69. - **ALIGN_LEFT** = **0** --- Aligns the text on the left hand side of the :ref:`LineEdit<class_lineedit>`.
  70. - **ALIGN_CENTER** = **1** --- Centers the text in the middle of the :ref:`LineEdit<class_lineedit>`.
  71. - **ALIGN_RIGHT** = **2** --- Aligns the text on the right hand side of the :ref:`LineEdit<class_lineedit>`.
  72. - **ALIGN_FILL** = **3** --- Stretches whitespaces to fit the :ref:`LineEdit<class_lineedit>`'s width.
  73. .. _enum_LineEdit_MenuItems:
  74. enum **MenuItems**
  75. - **MENU_CUT** = **0** --- Cuts (Copies and clears) the selected text.
  76. - **MENU_COPY** = **1** --- Copies the selected text.
  77. - **MENU_PASTE** = **2** --- Pastes the clipboard text over the selected text (or at the cursor's position).
  78. - **MENU_CLEAR** = **3** --- Erases the whole Linedit text.
  79. - **MENU_SELECT_ALL** = **4** --- Selects the whole Linedit text.
  80. - **MENU_UNDO** = **5** --- Undoes the previous action.
  81. - **MENU_REDO** = **6**
  82. - **MENU_MAX** = **7**
  83. Description
  84. -----------
  85. LineEdit provides a single line string editor, used for text fields.
  86. Member Function Description
  87. ---------------------------
  88. .. _class_LineEdit_append_at_cursor:
  89. - void **append_at_cursor** **(** :ref:`String<class_string>` text **)**
  90. Adds ``text`` after the cursor. If the resulting value is longer than :ref:`max_length<class_LineEdit_max_length>`, nothing happens.
  91. .. _class_LineEdit_clear:
  92. - void **clear** **(** **)**
  93. Erases the :ref:`LineEdit<class_lineedit>` text.
  94. .. _class_LineEdit_deselect:
  95. - void **deselect** **(** **)**
  96. Clears the current selection.
  97. .. _class_LineEdit_get_menu:
  98. - :ref:`PopupMenu<class_popupmenu>` **get_menu** **(** **)** const
  99. Returns the :ref:`PopupMenu<class_popupmenu>` of this ``LineEdit``. By default, this menu is displayed when right-clicking on the :ref:`LineEdit<class_lineedit>`.
  100. .. _class_LineEdit_menu_option:
  101. - void **menu_option** **(** :ref:`int<class_int>` option **)**
  102. Executes a given action as defined in the MENU\_\* enum.
  103. .. _class_LineEdit_select:
  104. - void **select** **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)**
  105. Selects characters inside :ref:`LineEdit<class_lineedit>` between ``from`` and ``to``. By default ``from`` is at the beginning and ``to`` at the end.
  106. ::
  107. text = "Welcome"
  108. select() # Welcome
  109. select(4) # ome
  110. select(2, 5) # lco
  111. .. _class_LineEdit_select_all:
  112. - void **select_all** **(** **)**
  113. Selects the whole :ref:`String<class_string>`.