class_lineedit.rst 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.5/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.5/doc/classes/LineEdit.xml.
  6. .. _class_LineEdit:
  7. LineEdit
  8. ========
  9. **Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Control that provides single-line string editing.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. LineEdit provides a single-line string editor, used for text fields.
  15. It features many built-in shortcuts which will always be available (``Ctrl`` here maps to ``Command`` on macOS):
  16. - Ctrl + C: Copy
  17. - Ctrl + X: Cut
  18. - Ctrl + V or Ctrl + Y: Paste/"yank"
  19. - Ctrl + Z: Undo
  20. - Ctrl + Shift + Z: Redo
  21. - Ctrl + U: Delete text from the cursor position to the beginning of the line
  22. - Ctrl + K: Delete text from the cursor position to the end of the line
  23. - Ctrl + A: Select all text
  24. - Up/Down arrow: Move the cursor to the beginning/end of the line
  25. On macOS, some extra keyboard shortcuts are available:
  26. - Ctrl + F: Like the right arrow key, move the cursor one character right
  27. - Ctrl + B: Like the left arrow key, move the cursor one character left
  28. - Ctrl + P: Like the up arrow key, move the cursor to the previous line
  29. - Ctrl + N: Like the down arrow key, move the cursor to the next line
  30. - Ctrl + D: Like the Delete key, delete the character on the right side of cursor
  31. - Ctrl + H: Like the Backspace key, delete the character on the left side of the cursor
  32. - Command + Left arrow: Like the Home key, move the cursor to the beginning of the line
  33. - Command + Right arrow: Like the End key, move the cursor to the end of the line
  34. .. rst-class:: classref-reftable-group
  35. Properties
  36. ----------
  37. .. table::
  38. :widths: auto
  39. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  40. | :ref:`Align<enum_LineEdit_Align>` | :ref:`align<class_LineEdit_property_align>` | ``0`` |
  41. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  42. | :ref:`bool<class_bool>` | :ref:`caret_blink<class_LineEdit_property_caret_blink>` | ``false`` |
  43. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  44. | :ref:`float<class_float>` | :ref:`caret_blink_speed<class_LineEdit_property_caret_blink_speed>` | ``0.65`` |
  45. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`caret_position<class_LineEdit_property_caret_position>` | ``0`` |
  47. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  48. | :ref:`bool<class_bool>` | :ref:`clear_button_enabled<class_LineEdit_property_clear_button_enabled>` | ``false`` |
  49. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`context_menu_enabled<class_LineEdit_property_context_menu_enabled>` | ``true`` |
  51. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`deselect_on_focus_loss_enabled<class_LineEdit_property_deselect_on_focus_loss_enabled>` | ``true`` |
  53. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`editable<class_LineEdit_property_editable>` | ``true`` |
  55. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`expand_to_text_length<class_LineEdit_property_expand_to_text_length>` | ``false`` |
  57. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  58. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``2`` (overrides :ref:`Control<class_Control_property_focus_mode>`) |
  59. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`max_length<class_LineEdit_property_max_length>` | ``0`` |
  61. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  62. | :ref:`bool<class_bool>` | :ref:`middle_mouse_paste_enabled<class_LineEdit_property_middle_mouse_paste_enabled>` | ``true`` |
  63. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  64. | :ref:`CursorShape<enum_Control_CursorShape>` | mouse_default_cursor_shape | ``1`` (overrides :ref:`Control<class_Control_property_mouse_default_cursor_shape>`) |
  65. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  66. | :ref:`float<class_float>` | :ref:`placeholder_alpha<class_LineEdit_property_placeholder_alpha>` | ``0.6`` |
  67. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  68. | :ref:`String<class_String>` | :ref:`placeholder_text<class_LineEdit_property_placeholder_text>` | ``""`` |
  69. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  70. | :ref:`Texture<class_Texture>` | :ref:`right_icon<class_LineEdit_property_right_icon>` | |
  71. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  72. | :ref:`bool<class_bool>` | :ref:`secret<class_LineEdit_property_secret>` | ``false`` |
  73. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  74. | :ref:`String<class_String>` | :ref:`secret_character<class_LineEdit_property_secret_character>` | ``"*"`` |
  75. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  76. | :ref:`bool<class_bool>` | :ref:`selecting_enabled<class_LineEdit_property_selecting_enabled>` | ``true`` |
  77. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  78. | :ref:`bool<class_bool>` | :ref:`shortcut_keys_enabled<class_LineEdit_property_shortcut_keys_enabled>` | ``true`` |
  79. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  80. | :ref:`String<class_String>` | :ref:`text<class_LineEdit_property_text>` | ``""`` |
  81. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  82. | :ref:`bool<class_bool>` | :ref:`virtual_keyboard_enabled<class_LineEdit_property_virtual_keyboard_enabled>` | ``true`` |
  83. +----------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  84. .. rst-class:: classref-reftable-group
  85. Methods
  86. -------
  87. .. table::
  88. :widths: auto
  89. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  90. | void | :ref:`append_at_cursor<class_LineEdit_method_append_at_cursor>` **(** :ref:`String<class_String>` text **)** |
  91. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`clear<class_LineEdit_method_clear>` **(** **)** |
  93. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`delete_char_at_cursor<class_LineEdit_method_delete_char_at_cursor>` **(** **)** |
  95. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`delete_text<class_LineEdit_method_delete_text>` **(** :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_column **)** |
  97. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`deselect<class_LineEdit_method_deselect>` **(** **)** |
  99. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  100. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_menu<class_LineEdit_method_get_menu>` **(** **)** |const| |
  101. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`int<class_int>` | :ref:`get_scroll_offset<class_LineEdit_method_get_scroll_offset>` **(** **)** |const| |
  103. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`int<class_int>` | :ref:`get_selection_from_column<class_LineEdit_method_get_selection_from_column>` **(** **)** |const| |
  105. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`get_selection_to_column<class_LineEdit_method_get_selection_to_column>` **(** **)** |const| |
  107. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`bool<class_bool>` | :ref:`has_selection<class_LineEdit_method_has_selection>` **(** **)** |const| |
  109. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`menu_option<class_LineEdit_method_menu_option>` **(** :ref:`int<class_int>` option **)** |
  111. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`select<class_LineEdit_method_select>` **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)** |
  113. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`select_all<class_LineEdit_method_select_all>` **(** **)** |
  115. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  116. .. rst-class:: classref-reftable-group
  117. Theme Properties
  118. ----------------
  119. .. table::
  120. :widths: auto
  121. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  122. | :ref:`Color<class_Color>` | :ref:`clear_button_color<class_LineEdit_theme_color_clear_button_color>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  123. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  124. | :ref:`Color<class_Color>` | :ref:`clear_button_color_pressed<class_LineEdit_theme_color_clear_button_color_pressed>` | ``Color( 1, 1, 1, 1 )`` |
  125. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  126. | :ref:`Color<class_Color>` | :ref:`cursor_color<class_LineEdit_theme_color_cursor_color>` | ``Color( 0.94, 0.94, 0.94, 1 )`` |
  127. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  128. | :ref:`Color<class_Color>` | :ref:`font_color<class_LineEdit_theme_color_font_color>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  129. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  130. | :ref:`Color<class_Color>` | :ref:`font_color_selected<class_LineEdit_theme_color_font_color_selected>` | ``Color( 0, 0, 0, 1 )`` |
  131. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  132. | :ref:`Color<class_Color>` | :ref:`font_color_uneditable<class_LineEdit_theme_color_font_color_uneditable>` | ``Color( 0.88, 0.88, 0.88, 0.5 )`` |
  133. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  134. | :ref:`Color<class_Color>` | :ref:`selection_color<class_LineEdit_theme_color_selection_color>` | ``Color( 0.49, 0.49, 0.49, 1 )`` |
  135. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  136. | :ref:`int<class_int>` | :ref:`minimum_spaces<class_LineEdit_theme_constant_minimum_spaces>` | ``12`` |
  137. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  138. | :ref:`Font<class_Font>` | :ref:`font<class_LineEdit_theme_font_font>` | |
  139. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  140. | :ref:`Texture<class_Texture>` | :ref:`clear<class_LineEdit_theme_icon_clear>` | |
  141. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  142. | :ref:`StyleBox<class_StyleBox>` | :ref:`focus<class_LineEdit_theme_style_focus>` | |
  143. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  144. | :ref:`StyleBox<class_StyleBox>` | :ref:`normal<class_LineEdit_theme_style_normal>` | |
  145. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  146. | :ref:`StyleBox<class_StyleBox>` | :ref:`read_only<class_LineEdit_theme_style_read_only>` | |
  147. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  148. .. rst-class:: classref-section-separator
  149. ----
  150. .. rst-class:: classref-descriptions-group
  151. Signals
  152. -------
  153. .. _class_LineEdit_signal_text_change_rejected:
  154. .. rst-class:: classref-signal
  155. **text_change_rejected** **(** :ref:`String<class_String>` rejected_substring **)**
  156. Emitted when appending text that overflows the :ref:`max_length<class_LineEdit_property_max_length>`. The appended text is truncated to fit :ref:`max_length<class_LineEdit_property_max_length>`, and the part that couldn't fit is passed as the ``rejected_substring`` argument.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_LineEdit_signal_text_changed:
  160. .. rst-class:: classref-signal
  161. **text_changed** **(** :ref:`String<class_String>` new_text **)**
  162. Emitted when the text changes.
  163. .. rst-class:: classref-item-separator
  164. ----
  165. .. _class_LineEdit_signal_text_entered:
  166. .. rst-class:: classref-signal
  167. **text_entered** **(** :ref:`String<class_String>` new_text **)**
  168. Emitted when the user presses :ref:`@GlobalScope.KEY_ENTER<class_@GlobalScope_constant_KEY_ENTER>` on the **LineEdit**.
  169. .. rst-class:: classref-section-separator
  170. ----
  171. .. rst-class:: classref-descriptions-group
  172. Enumerations
  173. ------------
  174. .. _enum_LineEdit_Align:
  175. .. rst-class:: classref-enumeration
  176. enum **Align**:
  177. .. _class_LineEdit_constant_ALIGN_LEFT:
  178. .. rst-class:: classref-enumeration-constant
  179. :ref:`Align<enum_LineEdit_Align>` **ALIGN_LEFT** = ``0``
  180. Aligns the text on the left-hand side of the **LineEdit**.
  181. .. _class_LineEdit_constant_ALIGN_CENTER:
  182. .. rst-class:: classref-enumeration-constant
  183. :ref:`Align<enum_LineEdit_Align>` **ALIGN_CENTER** = ``1``
  184. Centers the text in the middle of the **LineEdit**.
  185. .. _class_LineEdit_constant_ALIGN_RIGHT:
  186. .. rst-class:: classref-enumeration-constant
  187. :ref:`Align<enum_LineEdit_Align>` **ALIGN_RIGHT** = ``2``
  188. Aligns the text on the right-hand side of the **LineEdit**.
  189. .. _class_LineEdit_constant_ALIGN_FILL:
  190. .. rst-class:: classref-enumeration-constant
  191. :ref:`Align<enum_LineEdit_Align>` **ALIGN_FILL** = ``3``
  192. Stretches whitespaces to fit the **LineEdit**'s width.
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _enum_LineEdit_MenuItems:
  196. .. rst-class:: classref-enumeration
  197. enum **MenuItems**:
  198. .. _class_LineEdit_constant_MENU_CUT:
  199. .. rst-class:: classref-enumeration-constant
  200. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_CUT** = ``0``
  201. Cuts (copies and clears) the selected text.
  202. .. _class_LineEdit_constant_MENU_COPY:
  203. .. rst-class:: classref-enumeration-constant
  204. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_COPY** = ``1``
  205. Copies the selected text.
  206. .. _class_LineEdit_constant_MENU_PASTE:
  207. .. rst-class:: classref-enumeration-constant
  208. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_PASTE** = ``2``
  209. Pastes the clipboard text over the selected text (or at the cursor's position).
  210. Non-printable escape characters are automatically stripped from the OS clipboard via :ref:`String.strip_escapes<class_String_method_strip_escapes>`.
  211. .. _class_LineEdit_constant_MENU_CLEAR:
  212. .. rst-class:: classref-enumeration-constant
  213. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_CLEAR** = ``3``
  214. Erases the whole **LineEdit** text.
  215. .. _class_LineEdit_constant_MENU_SELECT_ALL:
  216. .. rst-class:: classref-enumeration-constant
  217. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_SELECT_ALL** = ``4``
  218. Selects the whole **LineEdit** text.
  219. .. _class_LineEdit_constant_MENU_UNDO:
  220. .. rst-class:: classref-enumeration-constant
  221. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_UNDO** = ``5``
  222. Undoes the previous action.
  223. .. _class_LineEdit_constant_MENU_REDO:
  224. .. rst-class:: classref-enumeration-constant
  225. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_REDO** = ``6``
  226. Reverse the last undo action.
  227. .. _class_LineEdit_constant_MENU_MAX:
  228. .. rst-class:: classref-enumeration-constant
  229. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_MAX** = ``7``
  230. Represents the size of the :ref:`MenuItems<enum_LineEdit_MenuItems>` enum.
  231. .. rst-class:: classref-section-separator
  232. ----
  233. .. rst-class:: classref-descriptions-group
  234. Property Descriptions
  235. ---------------------
  236. .. _class_LineEdit_property_align:
  237. .. rst-class:: classref-property
  238. :ref:`Align<enum_LineEdit_Align>` **align** = ``0``
  239. .. rst-class:: classref-property-setget
  240. - void **set_align** **(** :ref:`Align<enum_LineEdit_Align>` value **)**
  241. - :ref:`Align<enum_LineEdit_Align>` **get_align** **(** **)**
  242. Text alignment as defined in the :ref:`Align<enum_LineEdit_Align>` enum.
  243. .. rst-class:: classref-item-separator
  244. ----
  245. .. _class_LineEdit_property_caret_blink:
  246. .. rst-class:: classref-property
  247. :ref:`bool<class_bool>` **caret_blink** = ``false``
  248. .. rst-class:: classref-property-setget
  249. - void **cursor_set_blink_enabled** **(** :ref:`bool<class_bool>` value **)**
  250. - :ref:`bool<class_bool>` **cursor_get_blink_enabled** **(** **)**
  251. If ``true``, the caret (visual cursor) blinks.
  252. .. rst-class:: classref-item-separator
  253. ----
  254. .. _class_LineEdit_property_caret_blink_speed:
  255. .. rst-class:: classref-property
  256. :ref:`float<class_float>` **caret_blink_speed** = ``0.65``
  257. .. rst-class:: classref-property-setget
  258. - void **cursor_set_blink_speed** **(** :ref:`float<class_float>` value **)**
  259. - :ref:`float<class_float>` **cursor_get_blink_speed** **(** **)**
  260. Duration (in seconds) of a caret's blinking cycle.
  261. .. rst-class:: classref-item-separator
  262. ----
  263. .. _class_LineEdit_property_caret_position:
  264. .. rst-class:: classref-property
  265. :ref:`int<class_int>` **caret_position** = ``0``
  266. .. rst-class:: classref-property-setget
  267. - void **set_cursor_position** **(** :ref:`int<class_int>` value **)**
  268. - :ref:`int<class_int>` **get_cursor_position** **(** **)**
  269. The cursor's position inside the **LineEdit**. When set, the text may scroll to accommodate it.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_LineEdit_property_clear_button_enabled:
  273. .. rst-class:: classref-property
  274. :ref:`bool<class_bool>` **clear_button_enabled** = ``false``
  275. .. rst-class:: classref-property-setget
  276. - void **set_clear_button_enabled** **(** :ref:`bool<class_bool>` value **)**
  277. - :ref:`bool<class_bool>` **is_clear_button_enabled** **(** **)**
  278. If ``true``, the **LineEdit** will show a clear button if ``text`` is not empty, which can be used to clear the text quickly.
  279. .. rst-class:: classref-item-separator
  280. ----
  281. .. _class_LineEdit_property_context_menu_enabled:
  282. .. rst-class:: classref-property
  283. :ref:`bool<class_bool>` **context_menu_enabled** = ``true``
  284. .. rst-class:: classref-property-setget
  285. - void **set_context_menu_enabled** **(** :ref:`bool<class_bool>` value **)**
  286. - :ref:`bool<class_bool>` **is_context_menu_enabled** **(** **)**
  287. If ``true``, the context menu will appear when right-clicked.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_LineEdit_property_deselect_on_focus_loss_enabled:
  291. .. rst-class:: classref-property
  292. :ref:`bool<class_bool>` **deselect_on_focus_loss_enabled** = ``true``
  293. .. rst-class:: classref-property-setget
  294. - void **set_deselect_on_focus_loss_enabled** **(** :ref:`bool<class_bool>` value **)**
  295. - :ref:`bool<class_bool>` **is_deselect_on_focus_loss_enabled** **(** **)**
  296. If ``true``, the selected text will be deselected when focus is lost.
  297. .. rst-class:: classref-item-separator
  298. ----
  299. .. _class_LineEdit_property_editable:
  300. .. rst-class:: classref-property
  301. :ref:`bool<class_bool>` **editable** = ``true``
  302. .. rst-class:: classref-property-setget
  303. - void **set_editable** **(** :ref:`bool<class_bool>` value **)**
  304. - :ref:`bool<class_bool>` **is_editable** **(** **)**
  305. If ``false``, existing text cannot be modified and new text cannot be added.
  306. .. rst-class:: classref-item-separator
  307. ----
  308. .. _class_LineEdit_property_expand_to_text_length:
  309. .. rst-class:: classref-property
  310. :ref:`bool<class_bool>` **expand_to_text_length** = ``false``
  311. .. rst-class:: classref-property-setget
  312. - void **set_expand_to_text_length** **(** :ref:`bool<class_bool>` value **)**
  313. - :ref:`bool<class_bool>` **get_expand_to_text_length** **(** **)**
  314. If ``true``, the **LineEdit** width will increase to stay longer than the :ref:`text<class_LineEdit_property_text>`. It will **not** compress if the :ref:`text<class_LineEdit_property_text>` is shortened.
  315. .. rst-class:: classref-item-separator
  316. ----
  317. .. _class_LineEdit_property_max_length:
  318. .. rst-class:: classref-property
  319. :ref:`int<class_int>` **max_length** = ``0``
  320. .. rst-class:: classref-property-setget
  321. - void **set_max_length** **(** :ref:`int<class_int>` value **)**
  322. - :ref:`int<class_int>` **get_max_length** **(** **)**
  323. Maximum amount of characters that can be entered inside the **LineEdit**. If ``0``, there is no limit.
  324. When a limit is defined, characters that would exceed :ref:`max_length<class_LineEdit_property_max_length>` are truncated. This happens both for existing :ref:`text<class_LineEdit_property_text>` contents when setting the max length, or for new text inserted in the **LineEdit**, including pasting. If any input text is truncated, the :ref:`text_change_rejected<class_LineEdit_signal_text_change_rejected>` signal is emitted with the truncated substring as parameter.
  325. \ **Example:**\
  326. ::
  327. text = "Hello world"
  328. max_length = 5
  329. # `text` becomes "Hello".
  330. max_length = 10
  331. text += " goodbye"
  332. # `text` becomes "Hello good".
  333. # `text_change_rejected` is emitted with "bye" as parameter.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_LineEdit_property_middle_mouse_paste_enabled:
  337. .. rst-class:: classref-property
  338. :ref:`bool<class_bool>` **middle_mouse_paste_enabled** = ``true``
  339. .. rst-class:: classref-property-setget
  340. - void **set_middle_mouse_paste_enabled** **(** :ref:`bool<class_bool>` value **)**
  341. - :ref:`bool<class_bool>` **is_middle_mouse_paste_enabled** **(** **)**
  342. If ``false``, using middle mouse button to paste clipboard will be disabled.
  343. \ **Note:** This method is only implemented on Linux.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_LineEdit_property_placeholder_alpha:
  347. .. rst-class:: classref-property
  348. :ref:`float<class_float>` **placeholder_alpha** = ``0.6``
  349. .. rst-class:: classref-property-setget
  350. - void **set_placeholder_alpha** **(** :ref:`float<class_float>` value **)**
  351. - :ref:`float<class_float>` **get_placeholder_alpha** **(** **)**
  352. Opacity of the :ref:`placeholder_text<class_LineEdit_property_placeholder_text>`. From ``0`` to ``1``.
  353. .. rst-class:: classref-item-separator
  354. ----
  355. .. _class_LineEdit_property_placeholder_text:
  356. .. rst-class:: classref-property
  357. :ref:`String<class_String>` **placeholder_text** = ``""``
  358. .. rst-class:: classref-property-setget
  359. - void **set_placeholder** **(** :ref:`String<class_String>` value **)**
  360. - :ref:`String<class_String>` **get_placeholder** **(** **)**
  361. Text shown when the **LineEdit** is empty. It is **not** the **LineEdit**'s default value (see :ref:`text<class_LineEdit_property_text>`).
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_LineEdit_property_right_icon:
  365. .. rst-class:: classref-property
  366. :ref:`Texture<class_Texture>` **right_icon**
  367. .. rst-class:: classref-property-setget
  368. - void **set_right_icon** **(** :ref:`Texture<class_Texture>` value **)**
  369. - :ref:`Texture<class_Texture>` **get_right_icon** **(** **)**
  370. Sets the icon that will appear in the right end of the **LineEdit** if there's no :ref:`text<class_LineEdit_property_text>`, or always, if :ref:`clear_button_enabled<class_LineEdit_property_clear_button_enabled>` is set to ``false``.
  371. .. rst-class:: classref-item-separator
  372. ----
  373. .. _class_LineEdit_property_secret:
  374. .. rst-class:: classref-property
  375. :ref:`bool<class_bool>` **secret** = ``false``
  376. .. rst-class:: classref-property-setget
  377. - void **set_secret** **(** :ref:`bool<class_bool>` value **)**
  378. - :ref:`bool<class_bool>` **is_secret** **(** **)**
  379. If ``true``, every character is replaced with the secret character (see :ref:`secret_character<class_LineEdit_property_secret_character>`).
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_LineEdit_property_secret_character:
  383. .. rst-class:: classref-property
  384. :ref:`String<class_String>` **secret_character** = ``"*"``
  385. .. rst-class:: classref-property-setget
  386. - void **set_secret_character** **(** :ref:`String<class_String>` value **)**
  387. - :ref:`String<class_String>` **get_secret_character** **(** **)**
  388. The character to use to mask secret input (defaults to "\*"). Only a single character can be used as the secret character.
  389. .. rst-class:: classref-item-separator
  390. ----
  391. .. _class_LineEdit_property_selecting_enabled:
  392. .. rst-class:: classref-property
  393. :ref:`bool<class_bool>` **selecting_enabled** = ``true``
  394. .. rst-class:: classref-property-setget
  395. - void **set_selecting_enabled** **(** :ref:`bool<class_bool>` value **)**
  396. - :ref:`bool<class_bool>` **is_selecting_enabled** **(** **)**
  397. If ``false``, it's impossible to select the text using mouse nor keyboard.
  398. .. rst-class:: classref-item-separator
  399. ----
  400. .. _class_LineEdit_property_shortcut_keys_enabled:
  401. .. rst-class:: classref-property
  402. :ref:`bool<class_bool>` **shortcut_keys_enabled** = ``true``
  403. .. rst-class:: classref-property-setget
  404. - void **set_shortcut_keys_enabled** **(** :ref:`bool<class_bool>` value **)**
  405. - :ref:`bool<class_bool>` **is_shortcut_keys_enabled** **(** **)**
  406. If ``false``, using shortcuts will be disabled.
  407. .. rst-class:: classref-item-separator
  408. ----
  409. .. _class_LineEdit_property_text:
  410. .. rst-class:: classref-property
  411. :ref:`String<class_String>` **text** = ``""``
  412. .. rst-class:: classref-property-setget
  413. - void **set_text** **(** :ref:`String<class_String>` value **)**
  414. - :ref:`String<class_String>` **get_text** **(** **)**
  415. String value of the **LineEdit**.
  416. \ **Note:** Changing text using this property won't emit the :ref:`text_changed<class_LineEdit_signal_text_changed>` signal.
  417. .. rst-class:: classref-item-separator
  418. ----
  419. .. _class_LineEdit_property_virtual_keyboard_enabled:
  420. .. rst-class:: classref-property
  421. :ref:`bool<class_bool>` **virtual_keyboard_enabled** = ``true``
  422. .. rst-class:: classref-property-setget
  423. - void **set_virtual_keyboard_enabled** **(** :ref:`bool<class_bool>` value **)**
  424. - :ref:`bool<class_bool>` **is_virtual_keyboard_enabled** **(** **)**
  425. If ``true``, the native virtual keyboard is shown when focused on platforms that support it.
  426. .. rst-class:: classref-section-separator
  427. ----
  428. .. rst-class:: classref-descriptions-group
  429. Method Descriptions
  430. -------------------
  431. .. _class_LineEdit_method_append_at_cursor:
  432. .. rst-class:: classref-method
  433. void **append_at_cursor** **(** :ref:`String<class_String>` text **)**
  434. Adds ``text`` after the cursor. If the resulting value is longer than :ref:`max_length<class_LineEdit_property_max_length>`, nothing happens.
  435. .. rst-class:: classref-item-separator
  436. ----
  437. .. _class_LineEdit_method_clear:
  438. .. rst-class:: classref-method
  439. void **clear** **(** **)**
  440. Erases the **LineEdit**'s :ref:`text<class_LineEdit_property_text>`.
  441. .. rst-class:: classref-item-separator
  442. ----
  443. .. _class_LineEdit_method_delete_char_at_cursor:
  444. .. rst-class:: classref-method
  445. void **delete_char_at_cursor** **(** **)**
  446. Deletes one character at the cursor's current position (equivalent to pressing the ``Delete`` key).
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_LineEdit_method_delete_text:
  450. .. rst-class:: classref-method
  451. void **delete_text** **(** :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_column **)**
  452. Deletes a section of the :ref:`text<class_LineEdit_property_text>` going from position ``from_column`` to ``to_column``. Both parameters should be within the text's length.
  453. .. rst-class:: classref-item-separator
  454. ----
  455. .. _class_LineEdit_method_deselect:
  456. .. rst-class:: classref-method
  457. void **deselect** **(** **)**
  458. Clears the current selection.
  459. .. rst-class:: classref-item-separator
  460. ----
  461. .. _class_LineEdit_method_get_menu:
  462. .. rst-class:: classref-method
  463. :ref:`PopupMenu<class_PopupMenu>` **get_menu** **(** **)** |const|
  464. Returns the :ref:`PopupMenu<class_PopupMenu>` of this **LineEdit**. By default, this menu is displayed when right-clicking on the **LineEdit**.
  465. \ **Warning:** 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 :ref:`CanvasItem.visible<class_CanvasItem_property_visible>` property.
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_LineEdit_method_get_scroll_offset:
  469. .. rst-class:: classref-method
  470. :ref:`int<class_int>` **get_scroll_offset** **(** **)** |const|
  471. Returns the scroll offset due to :ref:`caret_position<class_LineEdit_property_caret_position>`, as a number of characters.
  472. .. rst-class:: classref-item-separator
  473. ----
  474. .. _class_LineEdit_method_get_selection_from_column:
  475. .. rst-class:: classref-method
  476. :ref:`int<class_int>` **get_selection_from_column** **(** **)** |const|
  477. Returns the selection begin column.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_LineEdit_method_get_selection_to_column:
  481. .. rst-class:: classref-method
  482. :ref:`int<class_int>` **get_selection_to_column** **(** **)** |const|
  483. Returns the selection end column.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_LineEdit_method_has_selection:
  487. .. rst-class:: classref-method
  488. :ref:`bool<class_bool>` **has_selection** **(** **)** |const|
  489. Returns ``true`` if the user has selected text.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_LineEdit_method_menu_option:
  493. .. rst-class:: classref-method
  494. void **menu_option** **(** :ref:`int<class_int>` option **)**
  495. Executes a given action as defined in the :ref:`MenuItems<enum_LineEdit_MenuItems>` enum.
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_LineEdit_method_select:
  499. .. rst-class:: classref-method
  500. void **select** **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)**
  501. Selects characters inside **LineEdit** between ``from`` and ``to``. By default, ``from`` is at the beginning and ``to`` at the end.
  502. ::
  503. text = "Welcome"
  504. select() # Will select "Welcome".
  505. select(4) # Will select "ome".
  506. select(2, 5) # Will select "lco".
  507. .. rst-class:: classref-item-separator
  508. ----
  509. .. _class_LineEdit_method_select_all:
  510. .. rst-class:: classref-method
  511. void **select_all** **(** **)**
  512. Selects the whole :ref:`String<class_String>`.
  513. .. rst-class:: classref-section-separator
  514. ----
  515. .. rst-class:: classref-descriptions-group
  516. Theme Property Descriptions
  517. ---------------------------
  518. .. _class_LineEdit_theme_color_clear_button_color:
  519. .. rst-class:: classref-themeproperty
  520. :ref:`Color<class_Color>` **clear_button_color** = ``Color( 0.88, 0.88, 0.88, 1 )``
  521. Color used as default tint for the clear button.
  522. .. rst-class:: classref-item-separator
  523. ----
  524. .. _class_LineEdit_theme_color_clear_button_color_pressed:
  525. .. rst-class:: classref-themeproperty
  526. :ref:`Color<class_Color>` **clear_button_color_pressed** = ``Color( 1, 1, 1, 1 )``
  527. Color used for the clear button when it's pressed.
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_LineEdit_theme_color_cursor_color:
  531. .. rst-class:: classref-themeproperty
  532. :ref:`Color<class_Color>` **cursor_color** = ``Color( 0.94, 0.94, 0.94, 1 )``
  533. Color of the **LineEdit**'s visual cursor (caret).
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_LineEdit_theme_color_font_color:
  537. .. rst-class:: classref-themeproperty
  538. :ref:`Color<class_Color>` **font_color** = ``Color( 0.88, 0.88, 0.88, 1 )``
  539. Default font color.
  540. .. rst-class:: classref-item-separator
  541. ----
  542. .. _class_LineEdit_theme_color_font_color_selected:
  543. .. rst-class:: classref-themeproperty
  544. :ref:`Color<class_Color>` **font_color_selected** = ``Color( 0, 0, 0, 1 )``
  545. Font color for selected text (inside the selection rectangle).
  546. .. rst-class:: classref-item-separator
  547. ----
  548. .. _class_LineEdit_theme_color_font_color_uneditable:
  549. .. rst-class:: classref-themeproperty
  550. :ref:`Color<class_Color>` **font_color_uneditable** = ``Color( 0.88, 0.88, 0.88, 0.5 )``
  551. Font color when editing is disabled.
  552. .. rst-class:: classref-item-separator
  553. ----
  554. .. _class_LineEdit_theme_color_selection_color:
  555. .. rst-class:: classref-themeproperty
  556. :ref:`Color<class_Color>` **selection_color** = ``Color( 0.49, 0.49, 0.49, 1 )``
  557. Color of the selection rectangle.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_LineEdit_theme_constant_minimum_spaces:
  561. .. rst-class:: classref-themeproperty
  562. :ref:`int<class_int>` **minimum_spaces** = ``12``
  563. Minimum horizontal space for the text (not counting the clear button and content margins). This value is measured in count of space characters (i.e. this amount of space characters can be displayed without scrolling).
  564. .. rst-class:: classref-item-separator
  565. ----
  566. .. _class_LineEdit_theme_font_font:
  567. .. rst-class:: classref-themeproperty
  568. :ref:`Font<class_Font>` **font**
  569. Font used for the text.
  570. .. rst-class:: classref-item-separator
  571. ----
  572. .. _class_LineEdit_theme_icon_clear:
  573. .. rst-class:: classref-themeproperty
  574. :ref:`Texture<class_Texture>` **clear**
  575. Texture for the clear button. See :ref:`clear_button_enabled<class_LineEdit_property_clear_button_enabled>`.
  576. .. rst-class:: classref-item-separator
  577. ----
  578. .. _class_LineEdit_theme_style_focus:
  579. .. rst-class:: classref-themeproperty
  580. :ref:`StyleBox<class_StyleBox>` **focus**
  581. Background used when **LineEdit** has GUI focus.
  582. .. rst-class:: classref-item-separator
  583. ----
  584. .. _class_LineEdit_theme_style_normal:
  585. .. rst-class:: classref-themeproperty
  586. :ref:`StyleBox<class_StyleBox>` **normal**
  587. Default background for the **LineEdit**.
  588. .. rst-class:: classref-item-separator
  589. ----
  590. .. _class_LineEdit_theme_style_read_only:
  591. .. rst-class:: classref-themeproperty
  592. :ref:`StyleBox<class_StyleBox>` **read_only**
  593. Background used when **LineEdit** is in read-only mode (:ref:`editable<class_LineEdit_property_editable>` is set to ``false``).
  594. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  595. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  596. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  597. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`