2
0

class_lineedit.rst 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604
  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/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/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. An input field for single-line text.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. **LineEdit** provides an input field for editing a single line of text. It features many built-in shortcuts that are always available (:kbd:`Ctrl` here maps to :kbd:`Cmd` on macOS):
  15. - :kbd:`Ctrl + C`: Copy
  16. - :kbd:`Ctrl + X`: Cut
  17. - :kbd:`Ctrl + V` or :kbd:`Ctrl + Y`: Paste/"yank"
  18. - :kbd:`Ctrl + Z`: Undo
  19. - :kbd:`Ctrl + ~`: Swap input direction.
  20. - :kbd:`Ctrl + Shift + Z`: Redo
  21. - :kbd:`Ctrl + U`: Delete text from the caret position to the beginning of the line
  22. - :kbd:`Ctrl + K`: Delete text from the caret position to the end of the line
  23. - :kbd:`Ctrl + A`: Select all text
  24. - :kbd:`Up Arrow`/:kbd:`Down Arrow`: Move the caret to the beginning/end of the line
  25. On macOS, some extra keyboard shortcuts are available:
  26. - :kbd:`Cmd + F`: Same as :kbd:`Right Arrow`, move the caret one character right
  27. - :kbd:`Cmd + B`: Same as :kbd:`Left Arrow`, move the caret one character left
  28. - :kbd:`Cmd + P`: Same as :kbd:`Up Arrow`, move the caret to the previous line
  29. - :kbd:`Cmd + N`: Same as :kbd:`Down Arrow`, move the caret to the next line
  30. - :kbd:`Cmd + D`: Same as :kbd:`Delete`, delete the character on the right side of caret
  31. - :kbd:`Cmd + H`: Same as :kbd:`Backspace`, delete the character on the left side of the caret
  32. - :kbd:`Cmd + A`: Same as :kbd:`Home`, move the caret to the beginning of the line
  33. - :kbd:`Cmd + E`: Same as :kbd:`End`, move the caret to the end of the line
  34. - :kbd:`Cmd + Left Arrow`: Same as :kbd:`Home`, move the caret to the beginning of the line
  35. - :kbd:`Cmd + Right Arrow`: Same as :kbd:`End`, move the caret to the end of the line
  36. .. rst-class:: classref-reftable-group
  37. Properties
  38. ----------
  39. .. table::
  40. :widths: auto
  41. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  42. | :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` | :ref:`alignment<class_LineEdit_property_alignment>` | ``0`` |
  43. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  44. | :ref:`bool<class_bool>` | :ref:`caret_blink<class_LineEdit_property_caret_blink>` | ``false`` |
  45. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`caret_blink_interval<class_LineEdit_property_caret_blink_interval>` | ``0.65`` |
  47. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`caret_column<class_LineEdit_property_caret_column>` | ``0`` |
  49. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  50. | :ref:`bool<class_bool>` | :ref:`caret_force_displayed<class_LineEdit_property_caret_force_displayed>` | ``false`` |
  51. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`caret_mid_grapheme<class_LineEdit_property_caret_mid_grapheme>` | ``true`` |
  53. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  54. | :ref:`bool<class_bool>` | :ref:`clear_button_enabled<class_LineEdit_property_clear_button_enabled>` | ``false`` |
  55. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  56. | :ref:`bool<class_bool>` | :ref:`context_menu_enabled<class_LineEdit_property_context_menu_enabled>` | ``true`` |
  57. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  58. | :ref:`bool<class_bool>` | :ref:`deselect_on_focus_loss_enabled<class_LineEdit_property_deselect_on_focus_loss_enabled>` | ``true`` |
  59. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  60. | :ref:`bool<class_bool>` | :ref:`draw_control_chars<class_LineEdit_property_draw_control_chars>` | ``false`` |
  61. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  62. | :ref:`bool<class_bool>` | :ref:`editable<class_LineEdit_property_editable>` | ``true`` |
  63. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  64. | :ref:`bool<class_bool>` | :ref:`expand_to_text_length<class_LineEdit_property_expand_to_text_length>` | ``false`` |
  65. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  66. | :ref:`bool<class_bool>` | :ref:`flat<class_LineEdit_property_flat>` | ``false`` |
  67. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  68. | :ref:`FocusMode<enum_Control_FocusMode>` | focus_mode | ``2`` (overrides :ref:`Control<class_Control_property_focus_mode>`) |
  69. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  70. | :ref:`String<class_String>` | :ref:`language<class_LineEdit_property_language>` | ``""`` |
  71. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  72. | :ref:`int<class_int>` | :ref:`max_length<class_LineEdit_property_max_length>` | ``0`` |
  73. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  74. | :ref:`bool<class_bool>` | :ref:`middle_mouse_paste_enabled<class_LineEdit_property_middle_mouse_paste_enabled>` | ``true`` |
  75. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  76. | :ref:`CursorShape<enum_Control_CursorShape>` | mouse_default_cursor_shape | ``1`` (overrides :ref:`Control<class_Control_property_mouse_default_cursor_shape>`) |
  77. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  78. | :ref:`String<class_String>` | :ref:`placeholder_text<class_LineEdit_property_placeholder_text>` | ``""`` |
  79. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  80. | :ref:`Texture2D<class_Texture2D>` | :ref:`right_icon<class_LineEdit_property_right_icon>` | |
  81. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  82. | :ref:`bool<class_bool>` | :ref:`secret<class_LineEdit_property_secret>` | ``false`` |
  83. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  84. | :ref:`String<class_String>` | :ref:`secret_character<class_LineEdit_property_secret_character>` | ``"•"`` |
  85. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  86. | :ref:`bool<class_bool>` | :ref:`select_all_on_focus<class_LineEdit_property_select_all_on_focus>` | ``false`` |
  87. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  88. | :ref:`bool<class_bool>` | :ref:`selecting_enabled<class_LineEdit_property_selecting_enabled>` | ``true`` |
  89. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  90. | :ref:`bool<class_bool>` | :ref:`shortcut_keys_enabled<class_LineEdit_property_shortcut_keys_enabled>` | ``true`` |
  91. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  92. | :ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>` | :ref:`structured_text_bidi_override<class_LineEdit_property_structured_text_bidi_override>` | ``0`` |
  93. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  94. | :ref:`Array<class_Array>` | :ref:`structured_text_bidi_override_options<class_LineEdit_property_structured_text_bidi_override_options>` | ``[]`` |
  95. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  96. | :ref:`String<class_String>` | :ref:`text<class_LineEdit_property_text>` | ``""`` |
  97. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  98. | :ref:`TextDirection<enum_Control_TextDirection>` | :ref:`text_direction<class_LineEdit_property_text_direction>` | ``0`` |
  99. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  100. | :ref:`bool<class_bool>` | :ref:`virtual_keyboard_enabled<class_LineEdit_property_virtual_keyboard_enabled>` | ``true`` |
  101. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  102. | :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` | :ref:`virtual_keyboard_type<class_LineEdit_property_virtual_keyboard_type>` | ``0`` |
  103. +-------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------+
  104. .. rst-class:: classref-reftable-group
  105. Methods
  106. -------
  107. .. table::
  108. :widths: auto
  109. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  110. | void | :ref:`clear<class_LineEdit_method_clear>` **(** **)** |
  111. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  112. | void | :ref:`delete_char_at_caret<class_LineEdit_method_delete_char_at_caret>` **(** **)** |
  113. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  114. | void | :ref:`delete_text<class_LineEdit_method_delete_text>` **(** :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_column **)** |
  115. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  116. | void | :ref:`deselect<class_LineEdit_method_deselect>` **(** **)** |
  117. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_menu<class_LineEdit_method_get_menu>` **(** **)** |const| |
  119. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`float<class_float>` | :ref:`get_scroll_offset<class_LineEdit_method_get_scroll_offset>` **(** **)** |const| |
  121. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`int<class_int>` | :ref:`get_selection_from_column<class_LineEdit_method_get_selection_from_column>` **(** **)** |const| |
  123. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`int<class_int>` | :ref:`get_selection_to_column<class_LineEdit_method_get_selection_to_column>` **(** **)** |const| |
  125. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`bool<class_bool>` | :ref:`has_selection<class_LineEdit_method_has_selection>` **(** **)** |const| |
  127. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  128. | void | :ref:`insert_text_at_caret<class_LineEdit_method_insert_text_at_caret>` **(** :ref:`String<class_String>` text **)** |
  129. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  130. | :ref:`bool<class_bool>` | :ref:`is_menu_visible<class_LineEdit_method_is_menu_visible>` **(** **)** |const| |
  131. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  132. | void | :ref:`menu_option<class_LineEdit_method_menu_option>` **(** :ref:`int<class_int>` option **)** |
  133. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  134. | void | :ref:`select<class_LineEdit_method_select>` **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)** |
  135. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  136. | void | :ref:`select_all<class_LineEdit_method_select_all>` **(** **)** |
  137. +-----------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+
  138. .. rst-class:: classref-reftable-group
  139. Theme Properties
  140. ----------------
  141. .. table::
  142. :widths: auto
  143. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  144. | :ref:`Color<class_Color>` | :ref:`caret_color<class_LineEdit_theme_color_caret_color>` | ``Color(0.95, 0.95, 0.95, 1)`` |
  145. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  146. | :ref:`Color<class_Color>` | :ref:`clear_button_color<class_LineEdit_theme_color_clear_button_color>` | ``Color(0.875, 0.875, 0.875, 1)`` |
  147. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  148. | :ref:`Color<class_Color>` | :ref:`clear_button_color_pressed<class_LineEdit_theme_color_clear_button_color_pressed>` | ``Color(1, 1, 1, 1)`` |
  149. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  150. | :ref:`Color<class_Color>` | :ref:`font_color<class_LineEdit_theme_color_font_color>` | ``Color(0.875, 0.875, 0.875, 1)`` |
  151. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  152. | :ref:`Color<class_Color>` | :ref:`font_outline_color<class_LineEdit_theme_color_font_outline_color>` | ``Color(1, 1, 1, 1)`` |
  153. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  154. | :ref:`Color<class_Color>` | :ref:`font_placeholder_color<class_LineEdit_theme_color_font_placeholder_color>` | ``Color(0.875, 0.875, 0.875, 0.6)`` |
  155. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  156. | :ref:`Color<class_Color>` | :ref:`font_selected_color<class_LineEdit_theme_color_font_selected_color>` | ``Color(1, 1, 1, 1)`` |
  157. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  158. | :ref:`Color<class_Color>` | :ref:`font_uneditable_color<class_LineEdit_theme_color_font_uneditable_color>` | ``Color(0.875, 0.875, 0.875, 0.5)`` |
  159. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  160. | :ref:`Color<class_Color>` | :ref:`selection_color<class_LineEdit_theme_color_selection_color>` | ``Color(0.5, 0.5, 0.5, 1)`` |
  161. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  162. | :ref:`int<class_int>` | :ref:`caret_width<class_LineEdit_theme_constant_caret_width>` | ``1`` |
  163. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  164. | :ref:`int<class_int>` | :ref:`minimum_character_width<class_LineEdit_theme_constant_minimum_character_width>` | ``4`` |
  165. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  166. | :ref:`int<class_int>` | :ref:`outline_size<class_LineEdit_theme_constant_outline_size>` | ``0`` |
  167. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  168. | :ref:`Font<class_Font>` | :ref:`font<class_LineEdit_theme_font_font>` | |
  169. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  170. | :ref:`int<class_int>` | :ref:`font_size<class_LineEdit_theme_font_size_font_size>` | |
  171. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  172. | :ref:`Texture2D<class_Texture2D>` | :ref:`clear<class_LineEdit_theme_icon_clear>` | |
  173. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  174. | :ref:`StyleBox<class_StyleBox>` | :ref:`focus<class_LineEdit_theme_style_focus>` | |
  175. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  176. | :ref:`StyleBox<class_StyleBox>` | :ref:`normal<class_LineEdit_theme_style_normal>` | |
  177. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  178. | :ref:`StyleBox<class_StyleBox>` | :ref:`read_only<class_LineEdit_theme_style_read_only>` | |
  179. +-----------------------------------+------------------------------------------------------------------------------------------+-------------------------------------+
  180. .. rst-class:: classref-section-separator
  181. ----
  182. .. rst-class:: classref-descriptions-group
  183. Signals
  184. -------
  185. .. _class_LineEdit_signal_text_change_rejected:
  186. .. rst-class:: classref-signal
  187. **text_change_rejected** **(** :ref:`String<class_String>` rejected_substring **)**
  188. 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.
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_LineEdit_signal_text_changed:
  192. .. rst-class:: classref-signal
  193. **text_changed** **(** :ref:`String<class_String>` new_text **)**
  194. Emitted when the text changes.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_LineEdit_signal_text_submitted:
  198. .. rst-class:: classref-signal
  199. **text_submitted** **(** :ref:`String<class_String>` new_text **)**
  200. Emitted when the user presses :ref:`@GlobalScope.KEY_ENTER<class_@GlobalScope_constant_KEY_ENTER>` on the **LineEdit**.
  201. .. rst-class:: classref-section-separator
  202. ----
  203. .. rst-class:: classref-descriptions-group
  204. Enumerations
  205. ------------
  206. .. _enum_LineEdit_MenuItems:
  207. .. rst-class:: classref-enumeration
  208. enum **MenuItems**:
  209. .. _class_LineEdit_constant_MENU_CUT:
  210. .. rst-class:: classref-enumeration-constant
  211. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_CUT** = ``0``
  212. Cuts (copies and clears) the selected text.
  213. .. _class_LineEdit_constant_MENU_COPY:
  214. .. rst-class:: classref-enumeration-constant
  215. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_COPY** = ``1``
  216. Copies the selected text.
  217. .. _class_LineEdit_constant_MENU_PASTE:
  218. .. rst-class:: classref-enumeration-constant
  219. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_PASTE** = ``2``
  220. Pastes the clipboard text over the selected text (or at the caret's position).
  221. Non-printable escape characters are automatically stripped from the OS clipboard via :ref:`String.strip_escapes<class_String_method_strip_escapes>`.
  222. .. _class_LineEdit_constant_MENU_CLEAR:
  223. .. rst-class:: classref-enumeration-constant
  224. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_CLEAR** = ``3``
  225. Erases the whole **LineEdit** text.
  226. .. _class_LineEdit_constant_MENU_SELECT_ALL:
  227. .. rst-class:: classref-enumeration-constant
  228. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_SELECT_ALL** = ``4``
  229. Selects the whole **LineEdit** text.
  230. .. _class_LineEdit_constant_MENU_UNDO:
  231. .. rst-class:: classref-enumeration-constant
  232. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_UNDO** = ``5``
  233. Undoes the previous action.
  234. .. _class_LineEdit_constant_MENU_REDO:
  235. .. rst-class:: classref-enumeration-constant
  236. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_REDO** = ``6``
  237. Reverse the last undo action.
  238. .. _class_LineEdit_constant_MENU_SUBMENU_TEXT_DIR:
  239. .. rst-class:: classref-enumeration-constant
  240. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_SUBMENU_TEXT_DIR** = ``7``
  241. ID of "Text Writing Direction" submenu.
  242. .. _class_LineEdit_constant_MENU_DIR_INHERITED:
  243. .. rst-class:: classref-enumeration-constant
  244. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_DIR_INHERITED** = ``8``
  245. Sets text direction to inherited.
  246. .. _class_LineEdit_constant_MENU_DIR_AUTO:
  247. .. rst-class:: classref-enumeration-constant
  248. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_DIR_AUTO** = ``9``
  249. Sets text direction to automatic.
  250. .. _class_LineEdit_constant_MENU_DIR_LTR:
  251. .. rst-class:: classref-enumeration-constant
  252. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_DIR_LTR** = ``10``
  253. Sets text direction to left-to-right.
  254. .. _class_LineEdit_constant_MENU_DIR_RTL:
  255. .. rst-class:: classref-enumeration-constant
  256. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_DIR_RTL** = ``11``
  257. Sets text direction to right-to-left.
  258. .. _class_LineEdit_constant_MENU_DISPLAY_UCC:
  259. .. rst-class:: classref-enumeration-constant
  260. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_DISPLAY_UCC** = ``12``
  261. Toggles control character display.
  262. .. _class_LineEdit_constant_MENU_SUBMENU_INSERT_UCC:
  263. .. rst-class:: classref-enumeration-constant
  264. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_SUBMENU_INSERT_UCC** = ``13``
  265. ID of "Insert Control Character" submenu.
  266. .. _class_LineEdit_constant_MENU_INSERT_LRM:
  267. .. rst-class:: classref-enumeration-constant
  268. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_LRM** = ``14``
  269. Inserts left-to-right mark (LRM) character.
  270. .. _class_LineEdit_constant_MENU_INSERT_RLM:
  271. .. rst-class:: classref-enumeration-constant
  272. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_RLM** = ``15``
  273. Inserts right-to-left mark (RLM) character.
  274. .. _class_LineEdit_constant_MENU_INSERT_LRE:
  275. .. rst-class:: classref-enumeration-constant
  276. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_LRE** = ``16``
  277. Inserts start of left-to-right embedding (LRE) character.
  278. .. _class_LineEdit_constant_MENU_INSERT_RLE:
  279. .. rst-class:: classref-enumeration-constant
  280. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_RLE** = ``17``
  281. Inserts start of right-to-left embedding (RLE) character.
  282. .. _class_LineEdit_constant_MENU_INSERT_LRO:
  283. .. rst-class:: classref-enumeration-constant
  284. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_LRO** = ``18``
  285. Inserts start of left-to-right override (LRO) character.
  286. .. _class_LineEdit_constant_MENU_INSERT_RLO:
  287. .. rst-class:: classref-enumeration-constant
  288. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_RLO** = ``19``
  289. Inserts start of right-to-left override (RLO) character.
  290. .. _class_LineEdit_constant_MENU_INSERT_PDF:
  291. .. rst-class:: classref-enumeration-constant
  292. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_PDF** = ``20``
  293. Inserts pop direction formatting (PDF) character.
  294. .. _class_LineEdit_constant_MENU_INSERT_ALM:
  295. .. rst-class:: classref-enumeration-constant
  296. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_ALM** = ``21``
  297. Inserts Arabic letter mark (ALM) character.
  298. .. _class_LineEdit_constant_MENU_INSERT_LRI:
  299. .. rst-class:: classref-enumeration-constant
  300. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_LRI** = ``22``
  301. Inserts left-to-right isolate (LRI) character.
  302. .. _class_LineEdit_constant_MENU_INSERT_RLI:
  303. .. rst-class:: classref-enumeration-constant
  304. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_RLI** = ``23``
  305. Inserts right-to-left isolate (RLI) character.
  306. .. _class_LineEdit_constant_MENU_INSERT_FSI:
  307. .. rst-class:: classref-enumeration-constant
  308. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_FSI** = ``24``
  309. Inserts first strong isolate (FSI) character.
  310. .. _class_LineEdit_constant_MENU_INSERT_PDI:
  311. .. rst-class:: classref-enumeration-constant
  312. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_PDI** = ``25``
  313. Inserts pop direction isolate (PDI) character.
  314. .. _class_LineEdit_constant_MENU_INSERT_ZWJ:
  315. .. rst-class:: classref-enumeration-constant
  316. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_ZWJ** = ``26``
  317. Inserts zero width joiner (ZWJ) character.
  318. .. _class_LineEdit_constant_MENU_INSERT_ZWNJ:
  319. .. rst-class:: classref-enumeration-constant
  320. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_ZWNJ** = ``27``
  321. Inserts zero width non-joiner (ZWNJ) character.
  322. .. _class_LineEdit_constant_MENU_INSERT_WJ:
  323. .. rst-class:: classref-enumeration-constant
  324. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_WJ** = ``28``
  325. Inserts word joiner (WJ) character.
  326. .. _class_LineEdit_constant_MENU_INSERT_SHY:
  327. .. rst-class:: classref-enumeration-constant
  328. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_INSERT_SHY** = ``29``
  329. Inserts soft hyphen (SHY) character.
  330. .. _class_LineEdit_constant_MENU_MAX:
  331. .. rst-class:: classref-enumeration-constant
  332. :ref:`MenuItems<enum_LineEdit_MenuItems>` **MENU_MAX** = ``30``
  333. Represents the size of the :ref:`MenuItems<enum_LineEdit_MenuItems>` enum.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _enum_LineEdit_VirtualKeyboardType:
  337. .. rst-class:: classref-enumeration
  338. enum **VirtualKeyboardType**:
  339. .. _class_LineEdit_constant_KEYBOARD_TYPE_DEFAULT:
  340. .. rst-class:: classref-enumeration-constant
  341. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_DEFAULT** = ``0``
  342. Default text virtual keyboard.
  343. .. _class_LineEdit_constant_KEYBOARD_TYPE_MULTILINE:
  344. .. rst-class:: classref-enumeration-constant
  345. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_MULTILINE** = ``1``
  346. Multiline virtual keyboard.
  347. .. _class_LineEdit_constant_KEYBOARD_TYPE_NUMBER:
  348. .. rst-class:: classref-enumeration-constant
  349. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_NUMBER** = ``2``
  350. Virtual number keypad, useful for PIN entry.
  351. .. _class_LineEdit_constant_KEYBOARD_TYPE_NUMBER_DECIMAL:
  352. .. rst-class:: classref-enumeration-constant
  353. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_NUMBER_DECIMAL** = ``3``
  354. Virtual number keypad, useful for entering fractional numbers.
  355. .. _class_LineEdit_constant_KEYBOARD_TYPE_PHONE:
  356. .. rst-class:: classref-enumeration-constant
  357. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_PHONE** = ``4``
  358. Virtual phone number keypad.
  359. .. _class_LineEdit_constant_KEYBOARD_TYPE_EMAIL_ADDRESS:
  360. .. rst-class:: classref-enumeration-constant
  361. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_EMAIL_ADDRESS** = ``5``
  362. Virtual keyboard with additional keys to assist with typing email addresses.
  363. .. _class_LineEdit_constant_KEYBOARD_TYPE_PASSWORD:
  364. .. rst-class:: classref-enumeration-constant
  365. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_PASSWORD** = ``6``
  366. Virtual keyboard for entering a password. On most platforms, this should disable autocomplete and autocapitalization.
  367. \ **Note:** This is not supported on Web. Instead, this behaves identically to :ref:`KEYBOARD_TYPE_DEFAULT<class_LineEdit_constant_KEYBOARD_TYPE_DEFAULT>`.
  368. .. _class_LineEdit_constant_KEYBOARD_TYPE_URL:
  369. .. rst-class:: classref-enumeration-constant
  370. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **KEYBOARD_TYPE_URL** = ``7``
  371. Virtual keyboard with additional keys to assist with typing URLs.
  372. .. rst-class:: classref-section-separator
  373. ----
  374. .. rst-class:: classref-descriptions-group
  375. Property Descriptions
  376. ---------------------
  377. .. _class_LineEdit_property_alignment:
  378. .. rst-class:: classref-property
  379. :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` **alignment** = ``0``
  380. .. rst-class:: classref-property-setget
  381. - void **set_horizontal_alignment** **(** :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` value **)**
  382. - :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` **get_horizontal_alignment** **(** **)**
  383. Text alignment as defined in the :ref:`HorizontalAlignment<enum_@GlobalScope_HorizontalAlignment>` enum.
  384. .. rst-class:: classref-item-separator
  385. ----
  386. .. _class_LineEdit_property_caret_blink:
  387. .. rst-class:: classref-property
  388. :ref:`bool<class_bool>` **caret_blink** = ``false``
  389. .. rst-class:: classref-property-setget
  390. - void **set_caret_blink_enabled** **(** :ref:`bool<class_bool>` value **)**
  391. - :ref:`bool<class_bool>` **is_caret_blink_enabled** **(** **)**
  392. If ``true``, the caret (text cursor) blinks.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_LineEdit_property_caret_blink_interval:
  396. .. rst-class:: classref-property
  397. :ref:`float<class_float>` **caret_blink_interval** = ``0.65``
  398. .. rst-class:: classref-property-setget
  399. - void **set_caret_blink_interval** **(** :ref:`float<class_float>` value **)**
  400. - :ref:`float<class_float>` **get_caret_blink_interval** **(** **)**
  401. Duration (in seconds) of a caret's blinking cycle.
  402. .. rst-class:: classref-item-separator
  403. ----
  404. .. _class_LineEdit_property_caret_column:
  405. .. rst-class:: classref-property
  406. :ref:`int<class_int>` **caret_column** = ``0``
  407. .. rst-class:: classref-property-setget
  408. - void **set_caret_column** **(** :ref:`int<class_int>` value **)**
  409. - :ref:`int<class_int>` **get_caret_column** **(** **)**
  410. The caret's column position inside the **LineEdit**. When set, the text may scroll to accommodate it.
  411. .. rst-class:: classref-item-separator
  412. ----
  413. .. _class_LineEdit_property_caret_force_displayed:
  414. .. rst-class:: classref-property
  415. :ref:`bool<class_bool>` **caret_force_displayed** = ``false``
  416. .. rst-class:: classref-property-setget
  417. - void **set_caret_force_displayed** **(** :ref:`bool<class_bool>` value **)**
  418. - :ref:`bool<class_bool>` **is_caret_force_displayed** **(** **)**
  419. If ``true``, the **LineEdit** will always show the caret, even if focus is lost.
  420. .. rst-class:: classref-item-separator
  421. ----
  422. .. _class_LineEdit_property_caret_mid_grapheme:
  423. .. rst-class:: classref-property
  424. :ref:`bool<class_bool>` **caret_mid_grapheme** = ``true``
  425. .. rst-class:: classref-property-setget
  426. - void **set_caret_mid_grapheme_enabled** **(** :ref:`bool<class_bool>` value **)**
  427. - :ref:`bool<class_bool>` **is_caret_mid_grapheme_enabled** **(** **)**
  428. Allow moving caret, selecting and removing the individual composite character components.
  429. \ **Note:** :kbd:`Backspace` is always removing individual composite character components.
  430. .. rst-class:: classref-item-separator
  431. ----
  432. .. _class_LineEdit_property_clear_button_enabled:
  433. .. rst-class:: classref-property
  434. :ref:`bool<class_bool>` **clear_button_enabled** = ``false``
  435. .. rst-class:: classref-property-setget
  436. - void **set_clear_button_enabled** **(** :ref:`bool<class_bool>` value **)**
  437. - :ref:`bool<class_bool>` **is_clear_button_enabled** **(** **)**
  438. If ``true``, the **LineEdit** will show a clear button if :ref:`text<class_LineEdit_property_text>` is not empty, which can be used to clear the text quickly.
  439. .. rst-class:: classref-item-separator
  440. ----
  441. .. _class_LineEdit_property_context_menu_enabled:
  442. .. rst-class:: classref-property
  443. :ref:`bool<class_bool>` **context_menu_enabled** = ``true``
  444. .. rst-class:: classref-property-setget
  445. - void **set_context_menu_enabled** **(** :ref:`bool<class_bool>` value **)**
  446. - :ref:`bool<class_bool>` **is_context_menu_enabled** **(** **)**
  447. If ``true``, the context menu will appear when right-clicked.
  448. .. rst-class:: classref-item-separator
  449. ----
  450. .. _class_LineEdit_property_deselect_on_focus_loss_enabled:
  451. .. rst-class:: classref-property
  452. :ref:`bool<class_bool>` **deselect_on_focus_loss_enabled** = ``true``
  453. .. rst-class:: classref-property-setget
  454. - void **set_deselect_on_focus_loss_enabled** **(** :ref:`bool<class_bool>` value **)**
  455. - :ref:`bool<class_bool>` **is_deselect_on_focus_loss_enabled** **(** **)**
  456. If ``true``, the selected text will be deselected when focus is lost.
  457. .. rst-class:: classref-item-separator
  458. ----
  459. .. _class_LineEdit_property_draw_control_chars:
  460. .. rst-class:: classref-property
  461. :ref:`bool<class_bool>` **draw_control_chars** = ``false``
  462. .. rst-class:: classref-property-setget
  463. - void **set_draw_control_chars** **(** :ref:`bool<class_bool>` value **)**
  464. - :ref:`bool<class_bool>` **get_draw_control_chars** **(** **)**
  465. If ``true``, control characters are displayed.
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_LineEdit_property_editable:
  469. .. rst-class:: classref-property
  470. :ref:`bool<class_bool>` **editable** = ``true``
  471. .. rst-class:: classref-property-setget
  472. - void **set_editable** **(** :ref:`bool<class_bool>` value **)**
  473. - :ref:`bool<class_bool>` **is_editable** **(** **)**
  474. If ``false``, existing text cannot be modified and new text cannot be added.
  475. .. rst-class:: classref-item-separator
  476. ----
  477. .. _class_LineEdit_property_expand_to_text_length:
  478. .. rst-class:: classref-property
  479. :ref:`bool<class_bool>` **expand_to_text_length** = ``false``
  480. .. rst-class:: classref-property-setget
  481. - void **set_expand_to_text_length_enabled** **(** :ref:`bool<class_bool>` value **)**
  482. - :ref:`bool<class_bool>` **is_expand_to_text_length_enabled** **(** **)**
  483. 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.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_LineEdit_property_flat:
  487. .. rst-class:: classref-property
  488. :ref:`bool<class_bool>` **flat** = ``false``
  489. .. rst-class:: classref-property-setget
  490. - void **set_flat** **(** :ref:`bool<class_bool>` value **)**
  491. - :ref:`bool<class_bool>` **is_flat** **(** **)**
  492. If ``true``, the **LineEdit** don't display decoration.
  493. .. rst-class:: classref-item-separator
  494. ----
  495. .. _class_LineEdit_property_language:
  496. .. rst-class:: classref-property
  497. :ref:`String<class_String>` **language** = ``""``
  498. .. rst-class:: classref-property-setget
  499. - void **set_language** **(** :ref:`String<class_String>` value **)**
  500. - :ref:`String<class_String>` **get_language** **(** **)**
  501. Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_LineEdit_property_max_length:
  505. .. rst-class:: classref-property
  506. :ref:`int<class_int>` **max_length** = ``0``
  507. .. rst-class:: classref-property-setget
  508. - void **set_max_length** **(** :ref:`int<class_int>` value **)**
  509. - :ref:`int<class_int>` **get_max_length** **(** **)**
  510. Maximum number of characters that can be entered inside the **LineEdit**. If ``0``, there is no limit.
  511. 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.
  512. \ **Example:**\
  513. .. tabs::
  514. .. code-tab:: gdscript
  515. text = "Hello world"
  516. max_length = 5
  517. # `text` becomes "Hello".
  518. max_length = 10
  519. text += " goodbye"
  520. # `text` becomes "Hello good".
  521. # `text_change_rejected` is emitted with "bye" as parameter.
  522. .. code-tab:: csharp
  523. Text = "Hello world";
  524. MaxLength = 5;
  525. // `Text` becomes "Hello".
  526. MaxLength = 10;
  527. Text += " goodbye";
  528. // `Text` becomes "Hello good".
  529. // `text_change_rejected` is emitted with "bye" as parameter.
  530. .. rst-class:: classref-item-separator
  531. ----
  532. .. _class_LineEdit_property_middle_mouse_paste_enabled:
  533. .. rst-class:: classref-property
  534. :ref:`bool<class_bool>` **middle_mouse_paste_enabled** = ``true``
  535. .. rst-class:: classref-property-setget
  536. - void **set_middle_mouse_paste_enabled** **(** :ref:`bool<class_bool>` value **)**
  537. - :ref:`bool<class_bool>` **is_middle_mouse_paste_enabled** **(** **)**
  538. If ``false``, using middle mouse button to paste clipboard will be disabled.
  539. \ **Note:** This method is only implemented on Linux.
  540. .. rst-class:: classref-item-separator
  541. ----
  542. .. _class_LineEdit_property_placeholder_text:
  543. .. rst-class:: classref-property
  544. :ref:`String<class_String>` **placeholder_text** = ``""``
  545. .. rst-class:: classref-property-setget
  546. - void **set_placeholder** **(** :ref:`String<class_String>` value **)**
  547. - :ref:`String<class_String>` **get_placeholder** **(** **)**
  548. Text shown when the **LineEdit** is empty. It is **not** the **LineEdit**'s default value (see :ref:`text<class_LineEdit_property_text>`).
  549. .. rst-class:: classref-item-separator
  550. ----
  551. .. _class_LineEdit_property_right_icon:
  552. .. rst-class:: classref-property
  553. :ref:`Texture2D<class_Texture2D>` **right_icon**
  554. .. rst-class:: classref-property-setget
  555. - void **set_right_icon** **(** :ref:`Texture2D<class_Texture2D>` value **)**
  556. - :ref:`Texture2D<class_Texture2D>` **get_right_icon** **(** **)**
  557. 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``.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_LineEdit_property_secret:
  561. .. rst-class:: classref-property
  562. :ref:`bool<class_bool>` **secret** = ``false``
  563. .. rst-class:: classref-property-setget
  564. - void **set_secret** **(** :ref:`bool<class_bool>` value **)**
  565. - :ref:`bool<class_bool>` **is_secret** **(** **)**
  566. If ``true``, every character is replaced with the secret character (see :ref:`secret_character<class_LineEdit_property_secret_character>`).
  567. .. rst-class:: classref-item-separator
  568. ----
  569. .. _class_LineEdit_property_secret_character:
  570. .. rst-class:: classref-property
  571. :ref:`String<class_String>` **secret_character** = ``"•"``
  572. .. rst-class:: classref-property-setget
  573. - void **set_secret_character** **(** :ref:`String<class_String>` value **)**
  574. - :ref:`String<class_String>` **get_secret_character** **(** **)**
  575. The character to use to mask secret input (defaults to "•"). Only a single character can be used as the secret character.
  576. .. rst-class:: classref-item-separator
  577. ----
  578. .. _class_LineEdit_property_select_all_on_focus:
  579. .. rst-class:: classref-property
  580. :ref:`bool<class_bool>` **select_all_on_focus** = ``false``
  581. .. rst-class:: classref-property-setget
  582. - void **set_select_all_on_focus** **(** :ref:`bool<class_bool>` value **)**
  583. - :ref:`bool<class_bool>` **is_select_all_on_focus** **(** **)**
  584. If ``true``, the **LineEdit** will select the whole text when it gains focus.
  585. .. rst-class:: classref-item-separator
  586. ----
  587. .. _class_LineEdit_property_selecting_enabled:
  588. .. rst-class:: classref-property
  589. :ref:`bool<class_bool>` **selecting_enabled** = ``true``
  590. .. rst-class:: classref-property-setget
  591. - void **set_selecting_enabled** **(** :ref:`bool<class_bool>` value **)**
  592. - :ref:`bool<class_bool>` **is_selecting_enabled** **(** **)**
  593. If ``false``, it's impossible to select the text using mouse nor keyboard.
  594. .. rst-class:: classref-item-separator
  595. ----
  596. .. _class_LineEdit_property_shortcut_keys_enabled:
  597. .. rst-class:: classref-property
  598. :ref:`bool<class_bool>` **shortcut_keys_enabled** = ``true``
  599. .. rst-class:: classref-property-setget
  600. - void **set_shortcut_keys_enabled** **(** :ref:`bool<class_bool>` value **)**
  601. - :ref:`bool<class_bool>` **is_shortcut_keys_enabled** **(** **)**
  602. If ``false``, using shortcuts will be disabled.
  603. .. rst-class:: classref-item-separator
  604. ----
  605. .. _class_LineEdit_property_structured_text_bidi_override:
  606. .. rst-class:: classref-property
  607. :ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>` **structured_text_bidi_override** = ``0``
  608. .. rst-class:: classref-property-setget
  609. - void **set_structured_text_bidi_override** **(** :ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>` value **)**
  610. - :ref:`StructuredTextParser<enum_TextServer_StructuredTextParser>` **get_structured_text_bidi_override** **(** **)**
  611. Set BiDi algorithm override for the structured text.
  612. .. rst-class:: classref-item-separator
  613. ----
  614. .. _class_LineEdit_property_structured_text_bidi_override_options:
  615. .. rst-class:: classref-property
  616. :ref:`Array<class_Array>` **structured_text_bidi_override_options** = ``[]``
  617. .. rst-class:: classref-property-setget
  618. - void **set_structured_text_bidi_override_options** **(** :ref:`Array<class_Array>` value **)**
  619. - :ref:`Array<class_Array>` **get_structured_text_bidi_override_options** **(** **)**
  620. Set additional options for BiDi override.
  621. .. rst-class:: classref-item-separator
  622. ----
  623. .. _class_LineEdit_property_text:
  624. .. rst-class:: classref-property
  625. :ref:`String<class_String>` **text** = ``""``
  626. .. rst-class:: classref-property-setget
  627. - void **set_text** **(** :ref:`String<class_String>` value **)**
  628. - :ref:`String<class_String>` **get_text** **(** **)**
  629. String value of the **LineEdit**.
  630. \ **Note:** Changing text using this property won't emit the :ref:`text_changed<class_LineEdit_signal_text_changed>` signal.
  631. .. rst-class:: classref-item-separator
  632. ----
  633. .. _class_LineEdit_property_text_direction:
  634. .. rst-class:: classref-property
  635. :ref:`TextDirection<enum_Control_TextDirection>` **text_direction** = ``0``
  636. .. rst-class:: classref-property-setget
  637. - void **set_text_direction** **(** :ref:`TextDirection<enum_Control_TextDirection>` value **)**
  638. - :ref:`TextDirection<enum_Control_TextDirection>` **get_text_direction** **(** **)**
  639. Base text writing direction.
  640. .. rst-class:: classref-item-separator
  641. ----
  642. .. _class_LineEdit_property_virtual_keyboard_enabled:
  643. .. rst-class:: classref-property
  644. :ref:`bool<class_bool>` **virtual_keyboard_enabled** = ``true``
  645. .. rst-class:: classref-property-setget
  646. - void **set_virtual_keyboard_enabled** **(** :ref:`bool<class_bool>` value **)**
  647. - :ref:`bool<class_bool>` **is_virtual_keyboard_enabled** **(** **)**
  648. If ``true``, the native virtual keyboard is shown when focused on platforms that support it.
  649. .. rst-class:: classref-item-separator
  650. ----
  651. .. _class_LineEdit_property_virtual_keyboard_type:
  652. .. rst-class:: classref-property
  653. :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **virtual_keyboard_type** = ``0``
  654. .. rst-class:: classref-property-setget
  655. - void **set_virtual_keyboard_type** **(** :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` value **)**
  656. - :ref:`VirtualKeyboardType<enum_LineEdit_VirtualKeyboardType>` **get_virtual_keyboard_type** **(** **)**
  657. Specifies the type of virtual keyboard to show.
  658. .. rst-class:: classref-section-separator
  659. ----
  660. .. rst-class:: classref-descriptions-group
  661. Method Descriptions
  662. -------------------
  663. .. _class_LineEdit_method_clear:
  664. .. rst-class:: classref-method
  665. void **clear** **(** **)**
  666. Erases the **LineEdit**'s :ref:`text<class_LineEdit_property_text>`.
  667. .. rst-class:: classref-item-separator
  668. ----
  669. .. _class_LineEdit_method_delete_char_at_caret:
  670. .. rst-class:: classref-method
  671. void **delete_char_at_caret** **(** **)**
  672. Deletes one character at the caret's current position (equivalent to pressing :kbd:`Delete`).
  673. .. rst-class:: classref-item-separator
  674. ----
  675. .. _class_LineEdit_method_delete_text:
  676. .. rst-class:: classref-method
  677. void **delete_text** **(** :ref:`int<class_int>` from_column, :ref:`int<class_int>` to_column **)**
  678. 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.
  679. .. rst-class:: classref-item-separator
  680. ----
  681. .. _class_LineEdit_method_deselect:
  682. .. rst-class:: classref-method
  683. void **deselect** **(** **)**
  684. Clears the current selection.
  685. .. rst-class:: classref-item-separator
  686. ----
  687. .. _class_LineEdit_method_get_menu:
  688. .. rst-class:: classref-method
  689. :ref:`PopupMenu<class_PopupMenu>` **get_menu** **(** **)** |const|
  690. Returns the :ref:`PopupMenu<class_PopupMenu>` of this **LineEdit**. By default, this menu is displayed when right-clicking on the **LineEdit**.
  691. You can add custom menu items or remove standard ones. Make sure your IDs don't conflict with the standard ones (see :ref:`MenuItems<enum_LineEdit_MenuItems>`). For example:
  692. .. tabs::
  693. .. code-tab:: gdscript
  694. func _ready():
  695. var menu = get_menu()
  696. # Remove all items after "Redo".
  697. menu.item_count = menu.get_item_index(MENU_REDO) + 1
  698. # Add custom items.
  699. menu.add_separator()
  700. menu.add_item("Insert Date", MENU_MAX + 1)
  701. # Connect callback.
  702. menu.id_pressed.connect(_on_item_pressed)
  703. func _on_item_pressed(id):
  704. if id == MENU_MAX + 1:
  705. insert_text_at_caret(Time.get_date_string_from_system())
  706. .. code-tab:: csharp
  707. public override void _Ready()
  708. {
  709. var menu = GetMenu();
  710. // Remove all items after "Redo".
  711. menu.ItemCount = menu.GetItemIndex(LineEdit.MenuItems.Redo) + 1;
  712. // Add custom items.
  713. menu.AddSeparator();
  714. menu.AddItem("Insert Date", LineEdit.MenuItems.Max + 1);
  715. // Add event handler.
  716. menu.IdPressed += OnItemPressed;
  717. }
  718. public void OnItemPressed(int id)
  719. {
  720. if (id == LineEdit.MenuItems.Max + 1)
  721. {
  722. InsertTextAtCaret(Time.GetDateStringFromSystem());
  723. }
  724. }
  725. \ **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:`Window.visible<class_Window_property_visible>` property.
  726. .. rst-class:: classref-item-separator
  727. ----
  728. .. _class_LineEdit_method_get_scroll_offset:
  729. .. rst-class:: classref-method
  730. :ref:`float<class_float>` **get_scroll_offset** **(** **)** |const|
  731. Returns the scroll offset due to :ref:`caret_column<class_LineEdit_property_caret_column>`, as a number of characters.
  732. .. rst-class:: classref-item-separator
  733. ----
  734. .. _class_LineEdit_method_get_selection_from_column:
  735. .. rst-class:: classref-method
  736. :ref:`int<class_int>` **get_selection_from_column** **(** **)** |const|
  737. Returns the selection begin column.
  738. .. rst-class:: classref-item-separator
  739. ----
  740. .. _class_LineEdit_method_get_selection_to_column:
  741. .. rst-class:: classref-method
  742. :ref:`int<class_int>` **get_selection_to_column** **(** **)** |const|
  743. Returns the selection end column.
  744. .. rst-class:: classref-item-separator
  745. ----
  746. .. _class_LineEdit_method_has_selection:
  747. .. rst-class:: classref-method
  748. :ref:`bool<class_bool>` **has_selection** **(** **)** |const|
  749. Returns ``true`` if the user has selected text.
  750. .. rst-class:: classref-item-separator
  751. ----
  752. .. _class_LineEdit_method_insert_text_at_caret:
  753. .. rst-class:: classref-method
  754. void **insert_text_at_caret** **(** :ref:`String<class_String>` text **)**
  755. Inserts ``text`` at the caret. If the resulting value is longer than :ref:`max_length<class_LineEdit_property_max_length>`, nothing happens.
  756. .. rst-class:: classref-item-separator
  757. ----
  758. .. _class_LineEdit_method_is_menu_visible:
  759. .. rst-class:: classref-method
  760. :ref:`bool<class_bool>` **is_menu_visible** **(** **)** |const|
  761. Returns whether the menu is visible. Use this instead of ``get_menu().visible`` to improve performance (so the creation of the menu is avoided).
  762. .. rst-class:: classref-item-separator
  763. ----
  764. .. _class_LineEdit_method_menu_option:
  765. .. rst-class:: classref-method
  766. void **menu_option** **(** :ref:`int<class_int>` option **)**
  767. Executes a given action as defined in the :ref:`MenuItems<enum_LineEdit_MenuItems>` enum.
  768. .. rst-class:: classref-item-separator
  769. ----
  770. .. _class_LineEdit_method_select:
  771. .. rst-class:: classref-method
  772. void **select** **(** :ref:`int<class_int>` from=0, :ref:`int<class_int>` to=-1 **)**
  773. Selects characters inside **LineEdit** between ``from`` and ``to``. By default, ``from`` is at the beginning and ``to`` at the end.
  774. .. tabs::
  775. .. code-tab:: gdscript
  776. text = "Welcome"
  777. select() # Will select "Welcome".
  778. select(4) # Will select "ome".
  779. select(2, 5) # Will select "lco".
  780. .. code-tab:: csharp
  781. Text = "Welcome";
  782. Select(); // Will select "Welcome".
  783. Select(4); // Will select "ome".
  784. Select(2, 5); // Will select "lco".
  785. .. rst-class:: classref-item-separator
  786. ----
  787. .. _class_LineEdit_method_select_all:
  788. .. rst-class:: classref-method
  789. void **select_all** **(** **)**
  790. Selects the whole :ref:`String<class_String>`.
  791. .. rst-class:: classref-section-separator
  792. ----
  793. .. rst-class:: classref-descriptions-group
  794. Theme Property Descriptions
  795. ---------------------------
  796. .. _class_LineEdit_theme_color_caret_color:
  797. .. rst-class:: classref-themeproperty
  798. :ref:`Color<class_Color>` **caret_color** = ``Color(0.95, 0.95, 0.95, 1)``
  799. Color of the **LineEdit**'s caret (text cursor). This can be set to a fully transparent color to hide the caret entirely.
  800. .. rst-class:: classref-item-separator
  801. ----
  802. .. _class_LineEdit_theme_color_clear_button_color:
  803. .. rst-class:: classref-themeproperty
  804. :ref:`Color<class_Color>` **clear_button_color** = ``Color(0.875, 0.875, 0.875, 1)``
  805. Color used as default tint for the clear button.
  806. .. rst-class:: classref-item-separator
  807. ----
  808. .. _class_LineEdit_theme_color_clear_button_color_pressed:
  809. .. rst-class:: classref-themeproperty
  810. :ref:`Color<class_Color>` **clear_button_color_pressed** = ``Color(1, 1, 1, 1)``
  811. Color used for the clear button when it's pressed.
  812. .. rst-class:: classref-item-separator
  813. ----
  814. .. _class_LineEdit_theme_color_font_color:
  815. .. rst-class:: classref-themeproperty
  816. :ref:`Color<class_Color>` **font_color** = ``Color(0.875, 0.875, 0.875, 1)``
  817. Default font color.
  818. .. rst-class:: classref-item-separator
  819. ----
  820. .. _class_LineEdit_theme_color_font_outline_color:
  821. .. rst-class:: classref-themeproperty
  822. :ref:`Color<class_Color>` **font_outline_color** = ``Color(1, 1, 1, 1)``
  823. The tint of text outline of the **LineEdit**.
  824. .. rst-class:: classref-item-separator
  825. ----
  826. .. _class_LineEdit_theme_color_font_placeholder_color:
  827. .. rst-class:: classref-themeproperty
  828. :ref:`Color<class_Color>` **font_placeholder_color** = ``Color(0.875, 0.875, 0.875, 0.6)``
  829. Font color for :ref:`placeholder_text<class_LineEdit_property_placeholder_text>`.
  830. .. rst-class:: classref-item-separator
  831. ----
  832. .. _class_LineEdit_theme_color_font_selected_color:
  833. .. rst-class:: classref-themeproperty
  834. :ref:`Color<class_Color>` **font_selected_color** = ``Color(1, 1, 1, 1)``
  835. Font color for selected text (inside the selection rectangle).
  836. .. rst-class:: classref-item-separator
  837. ----
  838. .. _class_LineEdit_theme_color_font_uneditable_color:
  839. .. rst-class:: classref-themeproperty
  840. :ref:`Color<class_Color>` **font_uneditable_color** = ``Color(0.875, 0.875, 0.875, 0.5)``
  841. Font color when editing is disabled.
  842. .. rst-class:: classref-item-separator
  843. ----
  844. .. _class_LineEdit_theme_color_selection_color:
  845. .. rst-class:: classref-themeproperty
  846. :ref:`Color<class_Color>` **selection_color** = ``Color(0.5, 0.5, 0.5, 1)``
  847. Color of the selection rectangle.
  848. .. rst-class:: classref-item-separator
  849. ----
  850. .. _class_LineEdit_theme_constant_caret_width:
  851. .. rst-class:: classref-themeproperty
  852. :ref:`int<class_int>` **caret_width** = ``1``
  853. The caret's width in pixels. Greater values can be used to improve accessibility by ensuring the caret is easily visible, or to ensure consistency with a large font size.
  854. .. rst-class:: classref-item-separator
  855. ----
  856. .. _class_LineEdit_theme_constant_minimum_character_width:
  857. .. rst-class:: classref-themeproperty
  858. :ref:`int<class_int>` **minimum_character_width** = ``4``
  859. Minimum horizontal space for the text (not counting the clear button and content margins). This value is measured in count of 'M' characters (i.e. this number of 'M' characters can be displayed without scrolling).
  860. .. rst-class:: classref-item-separator
  861. ----
  862. .. _class_LineEdit_theme_constant_outline_size:
  863. .. rst-class:: classref-themeproperty
  864. :ref:`int<class_int>` **outline_size** = ``0``
  865. The size of the text outline.
  866. \ **Note:** If using a font with :ref:`FontFile.multichannel_signed_distance_field<class_FontFile_property_multichannel_signed_distance_field>` enabled, its :ref:`FontFile.msdf_pixel_range<class_FontFile_property_msdf_pixel_range>` must be set to at least *twice* the value of :ref:`outline_size<class_LineEdit_theme_constant_outline_size>` for outline rendering to look correct. Otherwise, the outline may appear to be cut off earlier than intended.
  867. .. rst-class:: classref-item-separator
  868. ----
  869. .. _class_LineEdit_theme_font_font:
  870. .. rst-class:: classref-themeproperty
  871. :ref:`Font<class_Font>` **font**
  872. Font used for the text.
  873. .. rst-class:: classref-item-separator
  874. ----
  875. .. _class_LineEdit_theme_font_size_font_size:
  876. .. rst-class:: classref-themeproperty
  877. :ref:`int<class_int>` **font_size**
  878. Font size of the **LineEdit**'s text.
  879. .. rst-class:: classref-item-separator
  880. ----
  881. .. _class_LineEdit_theme_icon_clear:
  882. .. rst-class:: classref-themeproperty
  883. :ref:`Texture2D<class_Texture2D>` **clear**
  884. Texture for the clear button. See :ref:`clear_button_enabled<class_LineEdit_property_clear_button_enabled>`.
  885. .. rst-class:: classref-item-separator
  886. ----
  887. .. _class_LineEdit_theme_style_focus:
  888. .. rst-class:: classref-themeproperty
  889. :ref:`StyleBox<class_StyleBox>` **focus**
  890. Background used when **LineEdit** has GUI focus. The :ref:`focus<class_LineEdit_theme_style_focus>` :ref:`StyleBox<class_StyleBox>` is displayed *over* the base :ref:`StyleBox<class_StyleBox>`, so a partially transparent :ref:`StyleBox<class_StyleBox>` should be used to ensure the base :ref:`StyleBox<class_StyleBox>` remains visible. A :ref:`StyleBox<class_StyleBox>` that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a :ref:`StyleBoxEmpty<class_StyleBoxEmpty>` resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
  891. .. rst-class:: classref-item-separator
  892. ----
  893. .. _class_LineEdit_theme_style_normal:
  894. .. rst-class:: classref-themeproperty
  895. :ref:`StyleBox<class_StyleBox>` **normal**
  896. Default background for the **LineEdit**.
  897. .. rst-class:: classref-item-separator
  898. ----
  899. .. _class_LineEdit_theme_style_read_only:
  900. .. rst-class:: classref-themeproperty
  901. :ref:`StyleBox<class_StyleBox>` **read_only**
  902. Background used when **LineEdit** is in read-only mode (:ref:`editable<class_LineEdit_property_editable>` is set to ``false``).
  903. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  904. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  905. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  906. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  907. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  908. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`