Inherits: Control < CanvasItem < Node < Object
Control that provides single-line string editing.
LineEdit provides a single-line string editor, used for text fields.
It features many built-in shortcuts which will always be available (Ctrl
here maps to Command
on macOS):
On macOS, some extra keyboard shortcuts are available:
Align | align | 0 |
bool | caret_blink | false |
float | caret_blink_speed | 0.65 |
int | caret_position | 0 |
bool | clear_button_enabled | false |
bool | context_menu_enabled | true |
bool | editable | true |
bool | expand_to_text_length | false |
FocusMode | focus_mode |
2 (parent override)
|
int | max_length | 0 |
CursorShape | mouse_default_cursor_shape |
1 (parent override)
|
float | placeholder_alpha | 0.6 |
String | placeholder_text | "" |
Texture | right_icon | |
bool | secret | false |
String | secret_character | "*" |
bool | selecting_enabled | true |
bool | shortcut_keys_enabled | true |
String | text | "" |
bool | virtual_keyboard_enabled | true |
void | append_at_cursor ( String text ) |
void | clear ( ) |
void | delete_char_at_cursor ( ) |
void | delete_text ( int from_column, int to_column ) |
void | deselect ( ) |
PopupMenu | get_menu ( ) const |
void | menu_option ( int option ) |
void | select ( int from=0, int to=-1 ) |
void | select_all ( ) |
Texture | clear | |
Color | clear_button_color | Color( 0.88, 0.88, 0.88, 1 ) |
Color | clear_button_color_pressed | Color( 1, 1, 1, 1 ) |
Color | cursor_color | Color( 0.94, 0.94, 0.94, 1 ) |
StyleBox | focus | |
Font | font | |
Color | font_color | Color( 0.88, 0.88, 0.88, 1 ) |
Color | font_color_selected | Color( 0, 0, 0, 1 ) |
Color | font_color_uneditable | Color( 0.88, 0.88, 0.88, 0.5 ) |
int | minimum_spaces | 12 |
StyleBox | normal | |
StyleBox | read_only | |
Color | selection_color | Color( 0.49, 0.49, 0.49, 1 ) |
Emitted when trying to append text that would overflow the max_length.
Emitted when the text changes.
Emitted when the user presses @GlobalScope.KEY_ENTER on the LineEdit
.
enum Align:
LineEdit
.LineEdit
.LineEdit
.LineEdit
's width.Non-printable escape characters are automatically stripped from the OS clipboard via String.strip_escapes.
LineEdit
text.LineEdit
text.Default | 0 |
Setter | set_align(value) |
Getter | get_align() |
Text alignment as defined in the Align enum.
Default | false |
Setter | cursor_set_blink_enabled(value) |
Getter | cursor_get_blink_enabled() |
If true
, the caret (visual cursor) blinks.
Default | 0.65 |
Setter | cursor_set_blink_speed(value) |
Getter | cursor_get_blink_speed() |
Duration (in seconds) of a caret's blinking cycle.
Default | 0 |
Setter | set_cursor_position(value) |
Getter | get_cursor_position() |
The cursor's position inside the LineEdit
. When set, the text may scroll to accommodate it.
Default | false |
Setter | set_clear_button_enabled(value) |
Getter | is_clear_button_enabled() |
If true
, the LineEdit
will show a clear button if text
is not empty, which can be used to clear the text quickly.
Default | true |
Setter | set_context_menu_enabled(value) |
Getter | is_context_menu_enabled() |
If true
, the context menu will appear when right-clicked.
Default | true |
Setter | set_editable(value) |
Getter | is_editable() |
If false
, existing text cannot be modified and new text cannot be added.
Default | false |
Setter | set_expand_to_text_length(value) |
Getter | get_expand_to_text_length() |
If true
, the LineEdit
width will increase to stay longer than the text. It will not compress if the text is shortened.
Default | 0 |
Setter | set_max_length(value) |
Getter | get_max_length() |
Maximum amount of characters that can be entered inside the LineEdit
. If 0
, there is no limit.
Default | 0.6 |
Setter | set_placeholder_alpha(value) |
Getter | get_placeholder_alpha() |
Opacity of the placeholder_text. From 0
to 1
.
Default | "" |
Setter | set_placeholder(value) |
Getter | get_placeholder() |
Text shown when the LineEdit
is empty. It is not the LineEdit
's default value (see text).
Setter | set_right_icon(value) |
Getter | get_right_icon() |
Sets the icon that will appear in the right end of the LineEdit
if there's no text, or always, if clear_button_enabled is set to false
.
Default | false |
Setter | set_secret(value) |
Getter | is_secret() |
If true
, every character is replaced with the secret character (see secret_character).
Default | "*" |
Setter | set_secret_character(value) |
Getter | get_secret_character() |
The character to use to mask secret input (defaults to "*"). Only a single character can be used as the secret character.
Default | true |
Setter | set_selecting_enabled(value) |
Getter | is_selecting_enabled() |
If false
, it's impossible to select the text using mouse nor keyboard.
Default | true |
Setter | set_shortcut_keys_enabled(value) |
Getter | is_shortcut_keys_enabled() |
If false
, using shortcuts will be disabled.
Default | "" |
Setter | set_text(value) |
Getter | get_text() |
String value of the LineEdit
.
Note: Changing text using this property won't emit the text_changed signal.
Default | true |
Setter | set_virtual_keyboard_enabled(value) |
Getter | is_virtual_keyboard_enabled() |
If true
, the native virtual keyboard is shown when focused on platforms that support it.
Adds text
after the cursor. If the resulting value is longer than max_length, nothing happens.
Erases the LineEdit
's text.
Deletes one character at the cursor's current position (equivalent to pressing the Delete
key).
Deletes a section of the text going from position from_column
to to_column
. Both parameters should be within the text's length.
Clears the current selection.
Returns the PopupMenu of this LineEdit
. By default, this menu is displayed when right-clicking on the LineEdit
.
Executes a given action as defined in the MenuItems enum.
Selects characters inside LineEdit
between from
and to
. By default, from
is at the beginning and to
at the end.
text = "Welcome" select() # Will select "Welcome". select(4) # Will select "ome". select(2, 5) # Will select "lco".
Selects the whole String.
© 2014–2020 Juan Linietsky, Ariel Manzur, Godot Engine contributors
Licensed under the MIT License.
https://docs.godotengine.org/en/3.2/classes/class_lineedit.html