LineEdit¶
Inherits: Control < CanvasItem < Node < Object
Category: Core
Brief Description¶
Control that provides single line string editing.
Member Functions¶
void | append_at_cursor ( String text ) |
void | clear ( ) |
void | deselect ( ) |
PopupMenu | get_menu ( ) const |
void | menu_option ( int option ) |
void | select ( int from=0, int to=-1 ) |
void | select_all ( ) |
Signals¶
- text_changed ( String new_text )
Emitted when the text changes.
- text_entered ( String new_text )
Emitted when the user presses KEY_ENTER on the LineEdit
.
Member Variables¶
- Align align - Text alignment as defined in the ALIGN_* enum.
- bool caret_blink - If
true
the caret (visual cursor) blinks. - float caret_blink_speed - Duration (in seconds) of a caret’s blinking cycle.
- int caret_position - The cursor’s position inside the
LineEdit
. When set, the text may scroll to accommodate it. - bool editable - If
false
existing text cannot be modified and new text cannot be added. - bool 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. - FocusMode focus_mode - Defines how the LineEdit can grab focus (Keyboard and mouse, only keyboard, or none). See
enum FocusMode
in Control for details. - int max_length - Maximum amount of characters that can be entered inside the LineEdit. If
0
, there is no limit. - float placeholder_alpha - Opacity of the placeholder_text. From
0
to1
. - String placeholder_text - Text shown when the LineEdit is empty. It is not the LineEdit’s default value (see text).
- bool secret - If
true
every character is shown as “*”. - String text - String value of the LineEdit.
Enums¶
enum Align
- ALIGN_LEFT = 0 — Aligns the text on the left hand side of the LineEdit.
- ALIGN_CENTER = 1 — Centers the text in the middle of the LineEdit.
- ALIGN_RIGHT = 2 — Aligns the text on the right hand side of the LineEdit.
- ALIGN_FILL = 3 — Stretches whitespaces to fit the LineEdit’s width.
- MENU_CUT = 0 — Cuts (Copies and clears) the selected text.
- MENU_COPY = 1 — Copies the selected text.
- MENU_PASTE = 2 — Pastes the clipboard text over the selected text (or at the cursor’s position).
- MENU_CLEAR = 3 — Erases the whole Linedit text.
- MENU_SELECT_ALL = 4 — Selects the whole Linedit text.
- MENU_UNDO = 5 — Undoes the previous action.
- MENU_REDO = 6
- MENU_MAX = 7
Description¶
LineEdit provides a single line string editor, used for text fields.
Member Function Description¶
- void append_at_cursor ( String text )
Adds text
after the cursor. If the resulting value is longer than max_length, nothing happens.
- void clear ( )
Erases the LineEdit text.
- void deselect ( )
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 MENU_* enum.
Selects characters inside LineEdit between from
and to
. By default from
is at the beginning and to
at the end.
text = "Welcome"
select() # Welcome
select(4) # ome
select(2, 5) # lco
- void select_all ( )
Selects the whole String.