class_lineedit.rst 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  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.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/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. - :kbd:`Ctrl + C`: Copy
  17. - :kbd:`Ctrl + X`: Cut
  18. - :kbd:`Ctrl + V or Ctrl + Y`: Paste/"yank"
  19. - :kbd:`Ctrl + Z`: Undo
  20. - :kbd:`Ctrl + Shift + Z`: Redo
  21. - :kbd:`Ctrl + U`: Delete text from the cursor position to the beginning of the line
  22. - :kbd:`Ctrl + K`: Delete text from the cursor position to the end of the line
  23. - :kbd:`Ctrl + A`: Select all text
  24. - :kbd:`Up Arrow`/:kbd:`Down arrow`: Move the cursor to the beginning/end of the line
  25. On macOS, some extra keyboard shortcuts are available:
  26. - :kbd:`Ctrl + F`: Same as :kbd:`Right Arrow`, move the cursor one character right
  27. - :kbd:`Ctrl + B`: Same as :kbd:`Left Arrow`, move the cursor one character left
  28. - :kbd:`Ctrl + P`: Same as :kbd:`Up Arrow`, move the cursor to the previous line
  29. - :kbd:`Ctrl + N`: Same as :kbd:`Down Arrow`, move the cursor to the next line
  30. - :kbd:`Ctrl + D`: Same as :kbd:`Delete`, delete the character on the right side of cursor
  31. - :kbd:`Ctrl + H`: Same as :kbd:`Backspace`, delete the character on the left side of the cursor
  32. - :kbd:`Cmd + Left arrow`: Same as :kbd:`Home`, move the cursor to the beginning of the line
  33. - :kbd:`Cmd + Right arrow`: Same as :kbd:`End`, 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. | :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` | :ref:`virtual_keyboard_type<class_LineEdit_property_virtual_keyboard_type>` | ``0`` |
  85. +---------------------------------------------------------------+-----------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  86. .. rst-class:: classref-reftable-group
  87. Methods
  88. -------
  89. .. table::
  90. :widths: auto
  91. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  92. | void | :ref:`append_at_cursor<class_LineEdit_method_append_at_cursor>` **(** :ref:`String<class_String>` text **)** |
  93. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  94. | void | :ref:`clear<class_LineEdit_method_clear>` **(** **)** |
  95. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  96. | void | :ref:`delete_char_at_cursor<class_LineEdit_method_delete_char_at_cursor>` **(** **)** |
  97. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  98. | void | :ref:`delete_text<class_LineEdit_method_delete_text>` **(** :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_column **)** |
  99. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  100. | void | :ref:`deselect<class_LineEdit_method_deselect>` **(** **)** |
  101. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_menu<class_LineEdit_method_get_menu>` **(** **)** |const| |
  103. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  104. | :ref:`int<class_int>` | :ref:`get_scroll_offset<class_LineEdit_method_get_scroll_offset>` **(** **)** |const| |
  105. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`get_selection_from_column<class_LineEdit_method_get_selection_from_column>` **(** **)** |const| |
  107. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`int<class_int>` | :ref:`get_selection_to_column<class_LineEdit_method_get_selection_to_column>` **(** **)** |const| |
  109. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`bool<class_bool>` | :ref:`has_selection<class_LineEdit_method_has_selection>` **(** **)** |const| |
  111. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`menu_option<class_LineEdit_method_menu_option>` **(** :ref:`int<class_int>` option **)** |
  113. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`select<class_LineEdit_method_select>` **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)** |
  115. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`select_all<class_LineEdit_method_select_all>` **(** **)** |
  117. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  118. .. rst-class:: classref-reftable-group
  119. Theme Properties
  120. ----------------
  121. .. table::
  122. :widths: auto
  123. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  124. | :ref:`Color<class_Color>` | :ref:`clear_button_color<class_LineEdit_theme_color_clear_button_color>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  125. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  126. | :ref:`Color<class_Color>` | :ref:`clear_button_color_pressed<class_LineEdit_theme_color_clear_button_color_pressed>` | ``Color( 1, 1, 1, 1 )`` |
  127. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  128. | :ref:`Color<class_Color>` | :ref:`cursor_color<class_LineEdit_theme_color_cursor_color>` | ``Color( 0.94, 0.94, 0.94, 1 )`` |
  129. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  130. | :ref:`Color<class_Color>` | :ref:`font_color<class_LineEdit_theme_color_font_color>` | ``Color( 0.88, 0.88, 0.88, 1 )`` |
  131. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  132. | :ref:`Color<class_Color>` | :ref:`font_color_selected<class_LineEdit_theme_color_font_color_selected>` | ``Color( 0, 0, 0, 1 )`` |
  133. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  134. | :ref:`Color<class_Color>` | :ref:`font_color_uneditable<class_LineEdit_theme_color_font_color_uneditable>` | ``Color( 0.88, 0.88, 0.88, 0.5 )`` |
  135. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  136. | :ref:`Color<class_Color>` | :ref:`selection_color<class_LineEdit_theme_color_selection_color>` | ``Color( 0.49, 0.49, 0.49, 1 )`` |
  137. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  138. | :ref:`int<class_int>` | :ref:`minimum_spaces<class_LineEdit_theme_constant_minimum_spaces>` | ``12`` |
  139. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  140. | :ref:`Font<class_Font>` | :ref:`font<class_LineEdit_theme_font_font>` | |
  141. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  142. | :ref:`Texture<class_Texture>` | :ref:`clear<class_LineEdit_theme_icon_clear>` | |
  143. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  144. | :ref:`StyleBox<class_StyleBox>` | :ref:`focus<class_LineEdit_theme_style_focus>` | |
  145. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  146. | :ref:`StyleBox<class_StyleBox>` | :ref:`normal<class_LineEdit_theme_style_normal>` | |
  147. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  148. | :ref:`StyleBox<class_StyleBox>` | :ref:`read_only<class_LineEdit_theme_style_read_only>` | |
  149. +---------------------------------+------------------------------------------------------------------------------------------+------------------------------------+
  150. .. rst-class:: classref-section-separator
  151. ----
  152. .. rst-class:: classref-descriptions-group
  153. Signals
  154. -------
  155. .. _class_LineEdit_signal_text_change_rejected:
  156. .. rst-class:: classref-signal
  157. **text_change_rejected** **(** :ref:`String<class_String>` rejected_substring **)**
  158. 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.
  159. .. rst-class:: classref-item-separator
  160. ----
  161. .. _class_LineEdit_signal_text_changed:
  162. .. rst-class:: classref-signal
  163. **text_changed** **(** :ref:`String<class_String>` new_text **)**
  164. Emitted when the text changes.
  165. .. rst-class:: classref-item-separator
  166. ----
  167. .. _class_LineEdit_signal_text_entered:
  168. .. rst-class:: classref-signal
  169. **text_entered** **(** :ref:`String<class_String>` new_text **)**
  170. Emitted when the user presses :ref:`@GlobalScope.KEY_ENTER<class_@GlobalScope_constant_KEY_ENTER>` on the **LineEdit**.
  171. .. rst-class:: classref-section-separator
  172. ----
  173. .. rst-class:: classref-descriptions-group
  174. Enumerations
  175. ------------
  176. .. _enum_LineEdit_Align:
  177. .. rst-class:: classref-enumeration
  178. enum **Align**:
  179. .. _class_LineEdit_constant_ALIGN_LEFT:
  180. .. rst-class:: classref-enumeration-constant
  181. :ref:`Align<enum_LineEdit_Align>` **ALIGN_LEFT** = ``0``
  182. Aligns the text on the left-hand side of the **LineEdit**.
  183. .. _class_LineEdit_constant_ALIGN_CENTER:
  184. .. rst-class:: classref-enumeration-constant
  185. :ref:`Align<enum_LineEdit_Align>` **ALIGN_CENTER** = ``1``
  186. Centers the text in the middle of the **LineEdit**.
  187. .. _class_LineEdit_constant_ALIGN_RIGHT:
  188. .. rst-class:: classref-enumeration-constant
  189. :ref:`Align<enum_LineEdit_Align>` **ALIGN_RIGHT** = ``2``
  190. Aligns the text on the right-hand side of the **LineEdit**.
  191. .. _class_LineEdit_constant_ALIGN_FILL:
  192. .. rst-class:: classref-enumeration-constant
  193. :ref:`Align<enum_LineEdit_Align>` **ALIGN_FILL** = ``3``
  194. Stretches whitespaces to fit the **LineEdit**'s width.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _enum_LineEdit_MenuItems:
  198. .. rst-class:: classref-enumeration
  199. enum **MenuItems**:
  200. .. _class_LineEdit_constant_MENU_CUT:
  201. .. rst-class:: classref-enumeration-constant
  202. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_CUT** = ``0``
  203. Cuts (copies and clears) the selected text.
  204. .. _class_LineEdit_constant_MENU_COPY:
  205. .. rst-class:: classref-enumeration-constant
  206. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_COPY** = ``1``
  207. Copies the selected text.
  208. .. _class_LineEdit_constant_MENU_PASTE:
  209. .. rst-class:: classref-enumeration-constant
  210. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_PASTE** = ``2``
  211. Pastes the clipboard text over the selected text (or at the cursor's position).
  212. Non-printable escape characters are automatically stripped from the OS clipboard via :ref:`String.strip_escapes<class_String_method_strip_escapes>`.
  213. .. _class_LineEdit_constant_MENU_CLEAR:
  214. .. rst-class:: classref-enumeration-constant
  215. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_CLEAR** = ``3``
  216. Erases the whole **LineEdit** text.
  217. .. _class_LineEdit_constant_MENU_SELECT_ALL:
  218. .. rst-class:: classref-enumeration-constant
  219. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_SELECT_ALL** = ``4``
  220. Selects the whole **LineEdit** text.
  221. .. _class_LineEdit_constant_MENU_UNDO:
  222. .. rst-class:: classref-enumeration-constant
  223. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_UNDO** = ``5``
  224. Undoes the previous action.
  225. .. _class_LineEdit_constant_MENU_REDO:
  226. .. rst-class:: classref-enumeration-constant
  227. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_REDO** = ``6``
  228. Reverse the last undo action.
  229. .. _class_LineEdit_constant_MENU_MAX:
  230. .. rst-class:: classref-enumeration-constant
  231. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_MAX** = ``7``
  232. Represents the size of the :ref:`MenuItems<enum_LineEdit_MenuItems>` enum.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _enum_LineEdit_VirtualKeyboardType:
  236. .. rst-class:: classref-enumeration
  237. enum **VirtualKeyboardType**:
  238. .. _class_LineEdit_constant_KEYBOARD_TYPE_DEFAULT:
  239. .. rst-class:: classref-enumeration-constant
  240. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_DEFAULT** = ``0``
  241. Default text virtual keyboard.
  242. .. _class_LineEdit_constant_KEYBOARD_TYPE_MULTILINE:
  243. .. rst-class:: classref-enumeration-constant
  244. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_MULTILINE** = ``1``
  245. Multiline virtual keyboard.
  246. .. _class_LineEdit_constant_KEYBOARD_TYPE_NUMBER:
  247. .. rst-class:: classref-enumeration-constant
  248. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_NUMBER** = ``2``
  249. Virtual number keypad, useful for PIN entry.
  250. .. _class_LineEdit_constant_KEYBOARD_TYPE_NUMBER_DECIMAL:
  251. .. rst-class:: classref-enumeration-constant
  252. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_NUMBER_DECIMAL** = ``3``
  253. Virtual number keypad, useful for entering fractional numbers.
  254. .. _class_LineEdit_constant_KEYBOARD_TYPE_PHONE:
  255. .. rst-class:: classref-enumeration-constant
  256. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_PHONE** = ``4``
  257. Virtual phone number keypad.
  258. .. _class_LineEdit_constant_KEYBOARD_TYPE_EMAIL_ADDRESS:
  259. .. rst-class:: classref-enumeration-constant
  260. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_EMAIL_ADDRESS** = ``5``
  261. Virtual keyboard with additional keys to assist with typing email addresses.
  262. .. _class_LineEdit_constant_KEYBOARD_TYPE_PASSWORD:
  263. .. rst-class:: classref-enumeration-constant
  264. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_PASSWORD** = ``6``
  265. Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.
  266. \ **Note:** This is not supported on HTML5 or below iOS version 11.0. Instead, this will behave identically to :ref:`KEYBOARD_TYPE_DEFAULT<class_LineEdit_constant_KEYBOARD_TYPE_DEFAULT>`.
  267. .. _class_LineEdit_constant_KEYBOARD_TYPE_URL:
  268. .. rst-class:: classref-enumeration-constant
  269. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_URL** = ``7``
  270. Virtual keyboard with additional keys to assist with typing URLs.
  271. .. rst-class:: classref-section-separator
  272. ----
  273. .. rst-class:: classref-descriptions-group
  274. Property Descriptions
  275. ---------------------
  276. .. _class_LineEdit_property_align:
  277. .. rst-class:: classref-property
  278. :ref:`Align<enum_LineEdit_Align>` **align** = ``0``
  279. .. rst-class:: classref-property-setget
  280. - void **set_align** **(** :ref:`Align<enum_LineEdit_Align>` value **)**
  281. - :ref:`Align<enum_LineEdit_Align>` **get_align** **(** **)**
  282. Text alignment as defined in the :ref:`Align<enum_LineEdit_Align>` enum.
  283. .. rst-class:: classref-item-separator
  284. ----
  285. .. _class_LineEdit_property_caret_blink:
  286. .. rst-class:: classref-property
  287. :ref:`bool<class_bool>` **caret_blink** = ``false``
  288. .. rst-class:: classref-property-setget
  289. - void **cursor_set_blink_enabled** **(** :ref:`bool<class_bool>` value **)**
  290. - :ref:`bool<class_bool>` **cursor_get_blink_enabled** **(** **)**
  291. If ``true``, the caret (visual cursor) blinks.
  292. .. rst-class:: classref-item-separator
  293. ----
  294. .. _class_LineEdit_property_caret_blink_speed:
  295. .. rst-class:: classref-property
  296. :ref:`float<class_float>` **caret_blink_speed** = ``0.65``
  297. .. rst-class:: classref-property-setget
  298. - void **cursor_set_blink_speed** **(** :ref:`float<class_float>` value **)**
  299. - :ref:`float<class_float>` **cursor_get_blink_speed** **(** **)**
  300. Duration (in seconds) of a caret's blinking cycle.
  301. .. rst-class:: classref-item-separator
  302. ----
  303. .. _class_LineEdit_property_caret_position:
  304. .. rst-class:: classref-property
  305. :ref:`int<class_int>` **caret_position** = ``0``
  306. .. rst-class:: classref-property-setget
  307. - void **set_cursor_position** **(** :ref:`int<class_int>` value **)**
  308. - :ref:`int<class_int>` **get_cursor_position** **(** **)**
  309. The cursor's position inside the **LineEdit**. When set, the text may scroll to accommodate it.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_LineEdit_property_clear_button_enabled:
  313. .. rst-class:: classref-property
  314. :ref:`bool<class_bool>` **clear_button_enabled** = ``false``
  315. .. rst-class:: classref-property-setget
  316. - void **set_clear_button_enabled** **(** :ref:`bool<class_bool>` value **)**
  317. - :ref:`bool<class_bool>` **is_clear_button_enabled** **(** **)**
  318. If ``true``, the **LineEdit** will show a clear button if ``text`` is not empty, which can be used to clear the text quickly.
  319. .. rst-class:: classref-item-separator
  320. ----
  321. .. _class_LineEdit_property_context_menu_enabled:
  322. .. rst-class:: classref-property
  323. :ref:`bool<class_bool>` **context_menu_enabled** = ``true``
  324. .. rst-class:: classref-property-setget
  325. - void **set_context_menu_enabled** **(** :ref:`bool<class_bool>` value **)**
  326. - :ref:`bool<class_bool>` **is_context_menu_enabled** **(** **)**
  327. If ``true``, the context menu will appear when right-clicked.
  328. .. rst-class:: classref-item-separator
  329. ----
  330. .. _class_LineEdit_property_deselect_on_focus_loss_enabled:
  331. .. rst-class:: classref-property
  332. :ref:`bool<class_bool>` **deselect_on_focus_loss_enabled** = ``true``
  333. .. rst-class:: classref-property-setget
  334. - void **set_deselect_on_focus_loss_enabled** **(** :ref:`bool<class_bool>` value **)**
  335. - :ref:`bool<class_bool>` **is_deselect_on_focus_loss_enabled** **(** **)**
  336. If ``true``, the selected text will be deselected when focus is lost.
  337. .. rst-class:: classref-item-separator
  338. ----
  339. .. _class_LineEdit_property_editable:
  340. .. rst-class:: classref-property
  341. :ref:`bool<class_bool>` **editable** = ``true``
  342. .. rst-class:: classref-property-setget
  343. - void **set_editable** **(** :ref:`bool<class_bool>` value **)**
  344. - :ref:`bool<class_bool>` **is_editable** **(** **)**
  345. If ``false``, existing text cannot be modified and new text cannot be added.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_LineEdit_property_expand_to_text_length:
  349. .. rst-class:: classref-property
  350. :ref:`bool<class_bool>` **expand_to_text_length** = ``false``
  351. .. rst-class:: classref-property-setget
  352. - void **set_expand_to_text_length** **(** :ref:`bool<class_bool>` value **)**
  353. - :ref:`bool<class_bool>` **get_expand_to_text_length** **(** **)**
  354. 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.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_LineEdit_property_max_length:
  358. .. rst-class:: classref-property
  359. :ref:`int<class_int>` **max_length** = ``0``
  360. .. rst-class:: classref-property-setget
  361. - void **set_max_length** **(** :ref:`int<class_int>` value **)**
  362. - :ref:`int<class_int>` **get_max_length** **(** **)**
  363. Maximum amount of characters that can be entered inside the **LineEdit**. If ``0``, there is no limit.
  364. 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.
  365. \ **Example:**\
  366. ::
  367. text = "Hello world"
  368. max_length = 5
  369. # `text` becomes "Hello".
  370. max_length = 10
  371. text += " goodbye"
  372. # `text` becomes "Hello good".
  373. # `text_change_rejected` is emitted with "bye" as parameter.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_LineEdit_property_middle_mouse_paste_enabled:
  377. .. rst-class:: classref-property
  378. :ref:`bool<class_bool>` **middle_mouse_paste_enabled** = ``true``
  379. .. rst-class:: classref-property-setget
  380. - void **set_middle_mouse_paste_enabled** **(** :ref:`bool<class_bool>` value **)**
  381. - :ref:`bool<class_bool>` **is_middle_mouse_paste_enabled** **(** **)**
  382. If ``false``, using middle mouse button to paste clipboard will be disabled.
  383. \ **Note:** This method is only implemented on Linux.
  384. .. rst-class:: classref-item-separator
  385. ----
  386. .. _class_LineEdit_property_placeholder_alpha:
  387. .. rst-class:: classref-property
  388. :ref:`float<class_float>` **placeholder_alpha** = ``0.6``
  389. .. rst-class:: classref-property-setget
  390. - void **set_placeholder_alpha** **(** :ref:`float<class_float>` value **)**
  391. - :ref:`float<class_float>` **get_placeholder_alpha** **(** **)**
  392. Opacity of the :ref:`placeholder_text<class_LineEdit_property_placeholder_text>`. From ``0`` to ``1``.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_LineEdit_property_placeholder_text:
  396. .. rst-class:: classref-property
  397. :ref:`String<class_String>` **placeholder_text** = ``""``
  398. .. rst-class:: classref-property-setget
  399. - void **set_placeholder** **(** :ref:`String<class_String>` value **)**
  400. - :ref:`String<class_String>` **get_placeholder** **(** **)**
  401. Text shown when the **LineEdit** is empty. It is **not** the **LineEdit**'s default value (see :ref:`text<class_LineEdit_property_text>`).
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_LineEdit_property_right_icon:
  405. .. rst-class:: classref-property
  406. :ref:`Texture<class_Texture>` **right_icon**
  407. .. rst-class:: classref-property-setget
  408. - void **set_right_icon** **(** :ref:`Texture<class_Texture>` value **)**
  409. - :ref:`Texture<class_Texture>` **get_right_icon** **(** **)**
  410. 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``.
  411. .. rst-class:: classref-item-separator
  412. ----
  413. .. _class_LineEdit_property_secret:
  414. .. rst-class:: classref-property
  415. :ref:`bool<class_bool>` **secret** = ``false``
  416. .. rst-class:: classref-property-setget
  417. - void **set_secret** **(** :ref:`bool<class_bool>` value **)**
  418. - :ref:`bool<class_bool>` **is_secret** **(** **)**
  419. If ``true``, every character is replaced with the secret character (see :ref:`secret_character<class_LineEdit_property_secret_character>`).
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_LineEdit_property_secret_character:
  423. .. rst-class:: classref-property
  424. :ref:`String<class_String>` **secret_character** = ``"*"``
  425. .. rst-class:: classref-property-setget
  426. - void **set_secret_character** **(** :ref:`String<class_String>` value **)**
  427. - :ref:`String<class_String>` **get_secret_character** **(** **)**
  428. The character to use to mask secret input (defaults to "\*"). Only a single character can be used as the secret character.
  429. .. rst-class:: classref-item-separator
  430. ----
  431. .. _class_LineEdit_property_selecting_enabled:
  432. .. rst-class:: classref-property
  433. :ref:`bool<class_bool>` **selecting_enabled** = ``true``
  434. .. rst-class:: classref-property-setget
  435. - void **set_selecting_enabled** **(** :ref:`bool<class_bool>` value **)**
  436. - :ref:`bool<class_bool>` **is_selecting_enabled** **(** **)**
  437. If ``false``, it's impossible to select the text using mouse nor keyboard.
  438. .. rst-class:: classref-item-separator
  439. ----
  440. .. _class_LineEdit_property_shortcut_keys_enabled:
  441. .. rst-class:: classref-property
  442. :ref:`bool<class_bool>` **shortcut_keys_enabled** = ``true``
  443. .. rst-class:: classref-property-setget
  444. - void **set_shortcut_keys_enabled** **(** :ref:`bool<class_bool>` value **)**
  445. - :ref:`bool<class_bool>` **is_shortcut_keys_enabled** **(** **)**
  446. If ``false``, using shortcuts will be disabled.
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_LineEdit_property_text:
  450. .. rst-class:: classref-property
  451. :ref:`String<class_String>` **text** = ``""``
  452. .. rst-class:: classref-property-setget
  453. - void **set_text** **(** :ref:`String<class_String>` value **)**
  454. - :ref:`String<class_String>` **get_text** **(** **)**
  455. String value of the **LineEdit**.
  456. \ **Note:** Changing text using this property won't emit the :ref:`text_changed<class_LineEdit_signal_text_changed>` signal.
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_LineEdit_property_virtual_keyboard_enabled:
  460. .. rst-class:: classref-property
  461. :ref:`bool<class_bool>` **virtual_keyboard_enabled** = ``true``
  462. .. rst-class:: classref-property-setget
  463. - void **set_virtual_keyboard_enabled** **(** :ref:`bool<class_bool>` value **)**
  464. - :ref:`bool<class_bool>` **is_virtual_keyboard_enabled** **(** **)**
  465. If ``true``, the native virtual keyboard is shown when focused on platforms that support it.
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_LineEdit_property_virtual_keyboard_type:
  469. .. rst-class:: classref-property
  470. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **virtual_keyboard_type** = ``0``
  471. .. rst-class:: classref-property-setget
  472. - void **set_virtual_keyboard_type** **(** :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` value **)**
  473. - :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **get_virtual_keyboard_type** **(** **)**
  474. Specifies the type of virtual keyboard to show.
  475. .. rst-class:: classref-section-separator
  476. ----
  477. .. rst-class:: classref-descriptions-group
  478. Method Descriptions
  479. -------------------
  480. .. _class_LineEdit_method_append_at_cursor:
  481. .. rst-class:: classref-method
  482. void **append_at_cursor** **(** :ref:`String<class_String>` text **)**
  483. Adds ``text`` after the cursor. If the resulting value is longer than :ref:`max_length<class_LineEdit_property_max_length>`, nothing happens.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_LineEdit_method_clear:
  487. .. rst-class:: classref-method
  488. void **clear** **(** **)**
  489. Erases the **LineEdit**'s :ref:`text<class_LineEdit_property_text>`.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_LineEdit_method_delete_char_at_cursor:
  493. .. rst-class:: classref-method
  494. void **delete_char_at_cursor** **(** **)**
  495. Deletes one character at the cursor's current position (equivalent to pressing the ``Delete`` key).
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_LineEdit_method_delete_text:
  499. .. rst-class:: classref-method
  500. void **delete_text** **(** :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_column **)**
  501. 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.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_LineEdit_method_deselect:
  505. .. rst-class:: classref-method
  506. void **deselect** **(** **)**
  507. Clears the current selection.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_LineEdit_method_get_menu:
  511. .. rst-class:: classref-method
  512. :ref:`PopupMenu<class_PopupMenu>` **get_menu** **(** **)** |const|
  513. Returns the :ref:`PopupMenu<class_PopupMenu>` of this **LineEdit**. By default, this menu is displayed when right-clicking on the **LineEdit**.
  514. \ **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.
  515. .. rst-class:: classref-item-separator
  516. ----
  517. .. _class_LineEdit_method_get_scroll_offset:
  518. .. rst-class:: classref-method
  519. :ref:`int<class_int>` **get_scroll_offset** **(** **)** |const|
  520. Returns the scroll offset due to :ref:`caret_position<class_LineEdit_property_caret_position>`, as a number of characters.
  521. .. rst-class:: classref-item-separator
  522. ----
  523. .. _class_LineEdit_method_get_selection_from_column:
  524. .. rst-class:: classref-method
  525. :ref:`int<class_int>` **get_selection_from_column** **(** **)** |const|
  526. Returns the selection begin column.
  527. .. rst-class:: classref-item-separator
  528. ----
  529. .. _class_LineEdit_method_get_selection_to_column:
  530. .. rst-class:: classref-method
  531. :ref:`int<class_int>` **get_selection_to_column** **(** **)** |const|
  532. Returns the selection end column.
  533. .. rst-class:: classref-item-separator
  534. ----
  535. .. _class_LineEdit_method_has_selection:
  536. .. rst-class:: classref-method
  537. :ref:`bool<class_bool>` **has_selection** **(** **)** |const|
  538. Returns ``true`` if the user has selected text.
  539. .. rst-class:: classref-item-separator
  540. ----
  541. .. _class_LineEdit_method_menu_option:
  542. .. rst-class:: classref-method
  543. void **menu_option** **(** :ref:`int<class_int>` option **)**
  544. Executes a given action as defined in the :ref:`MenuItems<enum_LineEdit_MenuItems>` enum.
  545. .. rst-class:: classref-item-separator
  546. ----
  547. .. _class_LineEdit_method_select:
  548. .. rst-class:: classref-method
  549. void **select** **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)**
  550. Selects characters inside **LineEdit** between ``from`` and ``to``. By default, ``from`` is at the beginning and ``to`` at the end.
  551. ::
  552. text = "Welcome"
  553. select() # Will select "Welcome".
  554. select(4) # Will select "ome".
  555. select(2, 5) # Will select "lco".
  556. .. rst-class:: classref-item-separator
  557. ----
  558. .. _class_LineEdit_method_select_all:
  559. .. rst-class:: classref-method
  560. void **select_all** **(** **)**
  561. Selects the whole :ref:`String<class_String>`.
  562. .. rst-class:: classref-section-separator
  563. ----
  564. .. rst-class:: classref-descriptions-group
  565. Theme Property Descriptions
  566. ---------------------------
  567. .. _class_LineEdit_theme_color_clear_button_color:
  568. .. rst-class:: classref-themeproperty
  569. :ref:`Color<class_Color>` **clear_button_color** = ``Color( 0.88, 0.88, 0.88, 1 )``
  570. Color used as default tint for the clear button.
  571. .. rst-class:: classref-item-separator
  572. ----
  573. .. _class_LineEdit_theme_color_clear_button_color_pressed:
  574. .. rst-class:: classref-themeproperty
  575. :ref:`Color<class_Color>` **clear_button_color_pressed** = ``Color( 1, 1, 1, 1 )``
  576. Color used for the clear button when it's pressed.
  577. .. rst-class:: classref-item-separator
  578. ----
  579. .. _class_LineEdit_theme_color_cursor_color:
  580. .. rst-class:: classref-themeproperty
  581. :ref:`Color<class_Color>` **cursor_color** = ``Color( 0.94, 0.94, 0.94, 1 )``
  582. Color of the **LineEdit**'s visual cursor (caret).
  583. .. rst-class:: classref-item-separator
  584. ----
  585. .. _class_LineEdit_theme_color_font_color:
  586. .. rst-class:: classref-themeproperty
  587. :ref:`Color<class_Color>` **font_color** = ``Color( 0.88, 0.88, 0.88, 1 )``
  588. Default font color.
  589. .. rst-class:: classref-item-separator
  590. ----
  591. .. _class_LineEdit_theme_color_font_color_selected:
  592. .. rst-class:: classref-themeproperty
  593. :ref:`Color<class_Color>` **font_color_selected** = ``Color( 0, 0, 0, 1 )``
  594. Font color for selected text (inside the selection rectangle).
  595. .. rst-class:: classref-item-separator
  596. ----
  597. .. _class_LineEdit_theme_color_font_color_uneditable:
  598. .. rst-class:: classref-themeproperty
  599. :ref:`Color<class_Color>` **font_color_uneditable** = ``Color( 0.88, 0.88, 0.88, 0.5 )``
  600. Font color when editing is disabled.
  601. .. rst-class:: classref-item-separator
  602. ----
  603. .. _class_LineEdit_theme_color_selection_color:
  604. .. rst-class:: classref-themeproperty
  605. :ref:`Color<class_Color>` **selection_color** = ``Color( 0.49, 0.49, 0.49, 1 )``
  606. Color of the selection rectangle.
  607. .. rst-class:: classref-item-separator
  608. ----
  609. .. _class_LineEdit_theme_constant_minimum_spaces:
  610. .. rst-class:: classref-themeproperty
  611. :ref:`int<class_int>` **minimum_spaces** = ``12``
  612. 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).
  613. .. rst-class:: classref-item-separator
  614. ----
  615. .. _class_LineEdit_theme_font_font:
  616. .. rst-class:: classref-themeproperty
  617. :ref:`Font<class_Font>` **font**
  618. Font used for the text.
  619. .. rst-class:: classref-item-separator
  620. ----
  621. .. _class_LineEdit_theme_icon_clear:
  622. .. rst-class:: classref-themeproperty
  623. :ref:`Texture<class_Texture>` **clear**
  624. Texture for the clear button. See :ref:`clear_button_enabled<class_LineEdit_property_clear_button_enabled>`.
  625. .. rst-class:: classref-item-separator
  626. ----
  627. .. _class_LineEdit_theme_style_focus:
  628. .. rst-class:: classref-themeproperty
  629. :ref:`StyleBox<class_StyleBox>` **focus**
  630. Background used when **LineEdit** has GUI focus.
  631. .. rst-class:: classref-item-separator
  632. ----
  633. .. _class_LineEdit_theme_style_normal:
  634. .. rst-class:: classref-themeproperty
  635. :ref:`StyleBox<class_StyleBox>` **normal**
  636. Default background for the **LineEdit**.
  637. .. rst-class:: classref-item-separator
  638. ----
  639. .. _class_LineEdit_theme_style_read_only:
  640. .. rst-class:: classref-themeproperty
  641. :ref:`StyleBox<class_StyleBox>` **read_only**
  642. Background used when **LineEdit** is in read-only mode (:ref:`editable<class_LineEdit_property_editable>` is set to ``false``).
  643. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  644. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  645. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  646. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`