Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

LineEdit

Inherits: Control < CanvasItem < Node < Object

An input field for single-line text.

Description

LineEdit provides an input field for editing a single line of text. It features many built-in shortcuts that are always available (Ctrl here maps to Cmd on macOS):

  • Ctrl + C: Copy

  • Ctrl + X: Cut

  • Ctrl + V or Ctrl + Y: Paste/"yank"

  • Ctrl + Z: Undo

  • Ctrl + ~: Swap input direction.

  • Ctrl + Shift + Z: Redo

  • Ctrl + U: Delete text from the caret position to the beginning of the line

  • Ctrl + K: Delete text from the caret position to the end of the line

  • Ctrl + A: Select all text

  • Up Arrow/Down Arrow: Move the caret to the beginning/end of the line

On macOS, some extra keyboard shortcuts are available:

  • Cmd + F: Same as Right Arrow, move the caret one character right

  • Cmd + B: Same as Left Arrow, move the caret one character left

  • Cmd + P: Same as Up Arrow, move the caret to the previous line

  • Cmd + N: Same as Down Arrow, move the caret to the next line

  • Cmd + D: Same as Delete, delete the character on the right side of caret

  • Cmd + H: Same as Backspace, delete the character on the left side of the caret

  • Cmd + A: Same as Home, move the caret to the beginning of the line

  • Cmd + E: Same as End, move the caret to the end of the line

  • Cmd + Left Arrow: Same as Home, move the caret to the beginning of the line

  • Cmd + Right Arrow: Same as End, move the caret to the end of the line

Properties

HorizontalAlignment

alignment

0

bool

caret_blink

false

float

caret_blink_interval

0.65

int

caret_column

0

bool

caret_force_displayed

false

bool

caret_mid_grapheme

false

bool

clear_button_enabled

false

bool

context_menu_enabled

true

bool

deselect_on_focus_loss_enabled

true

bool

drag_and_drop_selection_enabled

true

bool

draw_control_chars

false

bool

editable

true

bool

expand_to_text_length

false

bool

flat

false

FocusMode

focus_mode

2 (overrides Control)

String

language

""

int

max_length

0

bool

middle_mouse_paste_enabled

true

CursorShape

mouse_default_cursor_shape

1 (overrides Control)

String

placeholder_text

""

Texture2D

right_icon

bool

secret

false

String

secret_character

"•"

bool

select_all_on_focus

false

bool

selecting_enabled

true

bool

shortcut_keys_enabled

true

StructuredTextParser

structured_text_bidi_override

0

Array

structured_text_bidi_override_options

[]

String

text

""

TextDirection

text_direction

0

bool

virtual_keyboard_enabled

true

VirtualKeyboardType

virtual_keyboard_type

0

Methods

void

clear ( )

void

delete_char_at_caret ( )

void

delete_text ( int from_column, int to_column )

void

deselect ( )

PopupMenu

get_menu ( ) const

float

get_scroll_offset ( ) const

String

get_selected_text ( )

int

get_selection_from_column ( ) const

int

get_selection_to_column ( ) const

bool

has_selection ( ) const

void

insert_text_at_caret ( String text )

bool

is_menu_visible ( ) const

void

menu_option ( int option )

void

select ( int from=0, int to=-1 )

void

select_all ( )

Theme Properties

Color

caret_color

Color(0.95, 0.95, 0.95, 1)

Color

clear_button_color

Color(0.875, 0.875, 0.875, 1)

Color

clear_button_color_pressed

Color(1, 1, 1, 1)

Color

font_color

Color(0.875, 0.875, 0.875, 1)

Color

font_outline_color

Color(1, 1, 1, 1)

Color

font_placeholder_color

Color(0.875, 0.875, 0.875, 0.6)

Color

font_selected_color

Color(1, 1, 1, 1)

Color

font_uneditable_color

Color(0.875, 0.875, 0.875, 0.5)

Color

selection_color

Color(0.5, 0.5, 0.5, 1)

int

caret_width

1

int

minimum_character_width

4

int

outline_size

0

Font

font

int

font_size

Texture2D</