class_lineedit.rst 34 KB

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