Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

LineEdit

繼承: Control < CanvasItem < Node < Object

單行文字的輸入欄位。

說明

LineEdit 提供了用於編輯單行文字的輸入框。

  • 通過鍵盤方向鍵聚焦 LineEdit 時只會獲得焦點,不會進入編輯模式。

  • 要進入編輯模式,請使用滑鼠點選控制項,另見 keep_editing_on_text_submit。

  • 要退出編輯模式,請點選 ui_text_submit 或 ui_cancel(預設為 Escape)動作。

  • 詳見 edit()、unedit()、is_editing()、editing_toggled。

輸入文字時,可以使用 Unicode、OEM、Windows Alt 程式碼來插入特殊字元:

  • 輸入 Unicode 碼位時,請按住 Alt 並通過小鍵盤輸入碼位。例如要輸入字元 á(U+00E1),請按住 Alt 並使用小鍵盤輸入 +E1(前置的零可以省略)。

  • 輸入 OEM 碼位時,請按住 Alt 並通過小鍵盤輸入碼位。例如要輸入字元 á(OEM 160),請按住 Alt 並使用小鍵盤輸入 160。

  • 輸入 Windows 碼位時,請按住 Alt 並通過小鍵盤輸入碼位。例如要輸入字元 á(Windows 0225)請按住 Alt 並使用小鍵盤輸入 0、2、2、5 。前置的零不能省略,因為 Windows 碼位需要用這些零來和 OEM 碼位進行區分。

重要:

  • 通過 ui_focus_next(預設為 Tab)、ui_focus_prev(預設為 Shift + Tab)或 Control.grab_focus() 聚焦 LineEdit 仍然會進入編輯模式(出於相容考慮)。

LineEdit 提供了很多始終可用的內建快捷鍵(此處的 Ctrl 在 macOS 上會映射到 Cmd):

  • Ctrl + C:複製

  • Ctrl + X:剪切

  • Ctrl + V 或 Ctrl + Y:複製/“抽取”

  • Ctrl + Z:復原

  • Ctrl + ~:切換輸入方向。

  • Ctrl + Shift + Z:取消復原

  • Ctrl + U:刪除從文字游標位置到行首的文字

  • Ctrl + K:刪除從文字游標位置到行尾的文字

  • Ctrl + A:選擇所有文字

  • Up Arrow/Down Arrow:將文字游標移動到行首/行尾

在 macOS 上,有一些額外的鍵盤快捷鍵可用:

  • Ctrl + F:同 Right Arrow,將文字游標向右移動一個字元

  • Ctrl + B:同 Left Arrow,將文字游標向左移動一個字元

  • Ctrl + P:同 Up Arrow,將文字游標移動到上一行

  • Ctrl + N:同 Down Arrow,將文字游標移動到下一行

  • Ctrl + D:同 Delete,刪除文字游標右側的字元

  • Ctrl + H:同 Backspace,刪除文字游標左側的字元

  • Ctrl + A:同 Home,將文字游標移動到行首

  • Ctrl + E:同 End,將文字游標移動到行首尾

  • Cmd + Left Arrow:同 Home,將文字游標移動到行首

  • Cmd + Right Arrow:同 End,將文字游標移動到行尾

注意:上述游標移動快捷鍵不受 shortcut_keys_enabled 的影響。

屬性

HorizontalAlignment

alignment

0

bool

backspace_deletes_composite_character_enabled

false

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

emoji_menu_enabled

true

bool

expand_to_text_length

false

bool

flat

false

FocusMode

focus_mode

2 (overrides Control)

ExpandMode

icon_expand_mode

0

bool

keep_editing_on_text_submit

false

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

float

right_icon_scale

1.0

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

bool

virtual_keyboard_show_on_focus

true

VirtualKeyboardType

virtual_keyboard_type

0

方法

void

apply_ime()

void

cancel_ime()

void

clear()

void

delete_char_at_caret()

void

delete_text(from_column: int, to_column: int)

void

deselect()

void

edit(hide_focus: bool = false)

PopupMenu

get_menu() const

int

get_next_composite_character_column(column: int) const

int

get_previous_composite_character_column(column: int) const

float

get_scroll_offset() const

String

get_selected_text()

int

get_selection_from_column() const

int

get_selection_to_column() const

bool

has_ime_text() const

bool

has_redo() const

bool

has_selection() const

bool

has_undo() const

void

insert_text_at_caret(text: String)

bool

is_editing() const

bool

is_menu_visible() const

void

menu_option(option: int)

void

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

void

select_all()

void

unedit()

主題屬性

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(0, 0, 0, 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

clear

StyleBox

focus

StyleBox

normal

StyleBox

read_only


訊號

editing_toggled(toggled_on: bool) 🔗

LineEdit 進入退出編輯模式時發出。


text_change_rejected(rejected_substring: String) 🔗

當追加的文字超過了 max_length 時觸發。追加後的文字會被截斷以適應 max_length,超出的部分會被作為 rejected_substring 參數傳遞。


text_changed(new_text: String) 🔗

當文字更改時觸發。


text_submitted(new_text: String) 🔗

當 LineEdit 擁有焦點時,使用者按下 ui_text_submit 動作(預設為 Enter 或 Kp Enter)發出。


列舉

enum MenuItems: 🔗

MenuItems MENU_CUT = 0

剪切(複製並刪除)選中的文字。

MenuItems MENU_COPY = 1

複製選中的文字。

MenuItems MENU_PASTE = 2

將剪貼簿中的文字貼上到選中文字之上(或者文字游標位置)。

會使用 String.strip_escapes() 自動剝離作業系統剪貼簿中不可列印的轉義字元。

MenuItems MENU_CLEAR = 3

刪除 LineEdit 中的全部文字。

MenuItems MENU_SELECT_ALL = 4

選中 LineEdit 中的全部文字。

MenuItems MENU_UNDO = 5

復原之前的操作。

MenuItems MENU_REDO = 6

反轉最後一個復原動作。

MenuItems MENU_SUBMENU_TEXT_DIR = 7

“文字書寫方向”子功能表的 ID。

MenuItems MENU_DIR_INHERITED = 8

將文字方向設定為繼承。

MenuItems MENU_DIR_AUTO = 9

將文字方向設定為自動。

MenuItems MENU_DIR_LTR = 10

將文字方向設定為從左至右。

MenuItems MENU_DIR_RTL = 11

將文字方向設定為從右至左。

MenuItems MENU_DISPLAY_UCC = 12

切換控制字元的顯示。

MenuItems MENU_SUBMENU_INSERT_UCC = 13

“插入控制字元”子功能表的 ID。

MenuItems MENU_INSERT_LRM = 14

插入從左至右旗標(LRM)字元。

MenuItems MENU_INSERT_RLM = 15

插入從右至左旗標(LRM)字元。

MenuItems MENU_INSERT_LRE = 16

插入開始從左至右嵌入(LRE)字元。

MenuItems MENU_INSERT_RLE = 17

插入開始從右至左嵌入(RLE)字元。

MenuItems MENU_INSERT_LRO = 18

插入開始從左至右強制(LRO)字元。

MenuItems MENU_INSERT_RLO = 19

插入開始從右至左嵌入(RLE)字元。

MenuItems MENU_INSERT_PDF = 20

插入退出方向格式化(PDF)字元。

MenuItems MENU_INSERT_ALM = 21

插入阿拉伯字母標記(ALM)字元。

MenuItems MENU_INSERT_LRI = 22

插入從左至右隔離(LRI)字元。

MenuItems MENU_INSERT_RLI = 23

插入從右至左隔離(RLI)字元。

MenuItems MENU_INSERT_FSI = 24

插入第一個強隔離(FSI)字元。

MenuItems MENU_INSERT_PDI = 25

插入退出方向隔離(PDI)字元。

MenuItems MENU_INSERT_ZWJ = 26

插入零寬連接子(ZWJ)字元。

MenuItems MENU_INSERT_ZWNJ = 27

插入零寬非連接子(ZWNJ)字元。

MenuItems MENU_INSERT_WJ = 28

插入文字連接子(WJ)字元。

MenuItems MENU_INSERT_SHY = 29

插入軟連字號(SHY)字元。

MenuItems MENU_EMOJI_AND_SYMBOL = 30

打開系統 Emoji 和符號拾取器。

MenuItems MENU_MAX = 31

代表 MenuItems 列舉的大小。


enum VirtualKeyboardType: 🔗

VirtualKeyboardType KEYBOARD_TYPE_DEFAULT = 0

預設文字虛擬鍵盤。

VirtualKeyboardType KEYBOARD_TYPE_MULTILINE = 1

多行虛擬鍵盤。

VirtualKeyboardType KEYBOARD_TYPE_NUMBER = 2

虛擬數位鍵盤,可用於 PIN 輸入。

VirtualKeyboardType KEYBOARD_TYPE_NUMBER_DECIMAL = 3

虛擬數位鍵盤,可用於輸入小數。

VirtualKeyboardType KEYBOARD_TYPE_PHONE = 4

虛擬手機號碼鍵盤。

VirtualKeyboardType KEYBOARD_TYPE_EMAIL_ADDRESS = 5

帶有附加鍵的虛擬鍵盤,可説明輸入電子郵寄地址。

VirtualKeyboardType KEYBOARD_TYPE_PASSWORD = 6

用於輸入密碼的虛擬鍵盤。在大多數平臺上,這應該會停用自動完成和自動首字母大寫功能。

注意:Web 平臺不支援。與 KEYBOARD_TYPE_DEFAULT 的行為相同。

VirtualKeyboardType KEYBOARD_TYPE_URL = 7

帶有附加鍵的虛擬鍵盤,可説明輸入 URL。


enum ExpandMode: 🔗

ExpandMode EXPAND_MODE_ORIGINAL_SIZE = 0

右側圖示使用原始大小。

ExpandMode EXPAND_MODE_FIT_TO_TEXT = 1

縮放右側圖示的大小以匹配文字大小。

ExpandMode EXPAND_MODE_FIT_TO_LINE_EDIT = 2

縮放右側圖示以適應 LineEdit。


屬性說明

HorizontalAlignment alignment = 0 🔗

文字的水平對齊方式。


bool backspace_deletes_composite_character_enabled = false 🔗

  • void set_backspace_deletes_composite_character_enabled(value: bool)

  • bool is_backspace_deletes_composite_character_enabled()

如果為 true 且 caret_mid_grapheme 為 false,則退格鍵會刪除完整的組合字元,例如 ❤️‍🩹,而不是刪除組合字元中的一部分。


  • void set_caret_blink_enabled(value: bool)

  • bool is_caret_blink_enabled()

如果為 true,則文字游標會閃爍。


  • void set_caret_blink_interval(value: float)

  • float get_caret_blink_interval()

文字游標的閃爍間隔(單位為秒)。


int caret_column = 0 🔗

  • void set_caret_column(value: int)

  • int get_caret_column()

LineEdit 中游標的列位置。設定後文字可能會捲動以適應它。


bool caret_force_displayed = false 🔗

  • void set_caret_force_displayed(value: bool)

  • bool is_caret_force_displayed()

如果為 true,則該 LineEdit 會始終顯示游標,即使不處於編輯模式或焦點丟失。


bool caret_mid_grapheme = false 🔗

  • void set_caret_mid_grapheme_enabled(value: bool)

  • bool is_caret_mid_grapheme_enabled()

允許在單個複合字元的元件中進行移動游標、選中、刪除的操作。

注意:倒退鍵 Backspace 始終按複合字元的元件刪除。


bool clear_button_enabled = false 🔗

  • void set_clear_button_enabled(value: bool)

  • bool is_clear_button_enabled()

如果為 true,LineEdit 將在 text 非空時顯示清空按鈕,可以用來快速清除文字。


bool context_menu_enabled = true 🔗

  • void set_context_menu_enabled(value: bool)

  • bool is_context_menu_enabled()

如果為 true,按右鍵將出現本文選單。


bool deselect_on_focus_loss_enabled = true 🔗

  • void set_deselect_on_focus_loss_enabled(value: bool)

  • bool is_deselect_on_focus_loss_enabled()

如果為 true,則在丟失焦點時會取消選中文字。


bool drag_and_drop_selection_enabled = true 🔗

  • void set_drag_and_drop_selection_enabled(value: bool)

  • bool is_drag_and_drop_selection_enabled()

如果為 true,則允許拖放選中的文字。


bool draw_control_chars = false 🔗

  • void set_draw_control_chars(value: bool)

  • bool get_draw_control_chars()

如果為 true,則會顯示控制字元。


bool editable = true 🔗

  • void set_editable(value: bool)

  • bool is_editable()

如果為 false,則不能修改現在的文字,也不能新增新文字。


bool emoji_menu_enabled = true 🔗

  • void set_emoji_menu_enabled(value: bool)

  • bool is_emoji_menu_enabled()

如果為 true,則啟用“Emoji 和符號”選單。


bool expand_to_text_length = false 🔗

  • void set_expand_to_text_length_enabled(value: bool)

  • bool is_expand_to_text_length_enabled()

如果為 true,則 LineEdit 寬度將增加到比 text 長。如果 text 被縮短,它將不壓縮。


bool flat = false 🔗

  • void set_flat(value: bool)

  • bool is_flat()

如果為 true,則 LineEdit 不顯示裝飾。


ExpandMode icon_expand_mode = 0 🔗

定義 right_icon 的縮放行為。


bool keep_editing_on_text_submit = false 🔗

  • void set_keep_editing_on_text_submit(value: bool)

  • bool is_editing_kept_on_text_submit()

如果為 true,則按下 ui_text_submit 動作(預設為 Enter 或 Kp Enter)提交文字時 LineEdit 不會退出編輯模式。


String language = "" 🔗

用於斷行和文字塑形算法的語言程式碼。如果留空,則使用目前區域設定。


int max_length = 0 🔗

  • void set_max_length(value: int)

  • int get_max_length()

LineEdit 中可以輸入的最大字元數。如果為 0,則沒有限制。

定義限制後,將截斷超過 max_length 的字元。在設定最大長度時,將適用於現有的 text 內容,以及在 LineEdit 中插入、包括貼上進來的新文字。

如果輸入文字發生截斷,text_change_rejected 訊號將以截斷後的子字串作為參數發出。

text = "Hello world"
max_length = 5
# `text` 變為 "Hello"。
max_length = 10
text += " goodbye"
# `text` 變為 "Hello good"。
# `text_change_rejected` 以 "bye" 作為參數發出。

bool middle_mouse_paste_enabled = true 🔗

  • void set_middle_mouse_paste_enabled(value: bool)

  • bool is_middle_mouse_paste_enabled()

如果為 false,將停用滑鼠中鍵貼上剪貼簿。

注意:這個方法只在 Linux 上實作。


String placeholder_text = "" 🔗

  • void set_placeholder(value: String)

  • String get_placeholder()

當 LineEdit 為空時顯示的文字。它不是 LineEdit 的預設值(見 text)。


Texture2D right_icon 🔗

設定 LineEdit 右端的圖示,這個圖示會在沒有 text 時出現,如果 clear_button_enabled 為 false 則始終可見。


float right_icon_scale = 1.0 🔗

  • void set_right_icon_scale(value: float)

  • float get_right_icon_scale()

icon_expand_mode 設定為 EXPAND_MODE_FIT_TO_LINE_EDIT 時圖示的縮放比例。


bool secret = false 🔗

  • void set_secret(value: bool)

  • bool is_secret()

如果為 true,則每個字元都會被替換成密碼字元(見 secret_character)。


String secret_character = "•" 🔗

  • void set_secret_character(value: String)

  • String get_secret_character()

用於掩蓋秘密輸入的字元。只能用單個字元作為秘密字元。如果長度超過一個字元,則僅使用第一個字元。如果為空,則使用空白代替。


bool select_all_on_focus = false 🔗

  • void set_select_all_on_focus(value: bool)

  • bool is_select_all_on_focus()

如果為 true,則在獲得焦點時會全選文字。


bool selecting_enabled = true 🔗

  • void set_selecting_enabled(value: bool)

  • bool is_selecting_enabled()

如果為 false,則無法用滑鼠或鍵盤選擇文字。


bool shortcut_keys_enabled = true 🔗

  • void set_shortcut_keys_enabled(value: bool)

  • bool is_shortcut_keys_enabled()

為 true 時,即使本文選單已被停用,也會啟用該本文選單的快捷鍵。


StructuredTextParser structured_text_bidi_override = 0 🔗

為結構化文字設定 BiDi 演算法覆蓋。


Array structured_text_bidi_override_options = [] 🔗

  • void set_structured_text_bidi_override_options(value: Array)

  • Array get_structured_text_bidi_override_options()

設定 BiDi 覆蓋的附加選項。


String text = "" 🔗

LineEdit 的字串值。

注意:使用這個屬性更改文字不會觸發 text_changed 訊號。


TextDirection text_direction = 0 🔗

基礎文字書寫方向。


bool virtual_keyboard_enabled = true 🔗

  • void set_virtual_keyboard_enabled(value: bool)

  • bool is_virtual_keyboard_enabled()

如果為 true,則會在支援的平台上啟用原生虛擬鍵盤。


bool virtual_keyboard_show_on_focus = true 🔗

  • void set_virtual_keyboard_show_on_focus(value: bool)

  • bool get_virtual_keyboard_show_on_focus()

如果為 true,則在收到獲得焦點事件時會在支援的平台上顯示原生虛擬鍵盤。


VirtualKeyboardType virtual_keyboard_type = 0 🔗

指定要顯示的虛擬鍵盤的型別。


方法說明

void apply_ime() 🔗

應用輸入法編輯器中的文字,如果輸入法編輯器處於打開狀態,還會將其關閉。


void cancel_ime() 🔗

如果輸入法編輯器處於打開狀態,則會將其關閉。輸入法編輯器中的文字會丟失。


void clear() 🔗

擦除 LineEdit 的 text。


void delete_char_at_caret() 🔗

刪除游標目前位置處的一個字元(相當於按 Delete)。


void delete_text(from_column: int, to_column: int) 🔗

刪除 text 中從起始列 from_column 到結束列 to_column 的部分。兩個參數都應該在文字的長度之內。


void deselect() 🔗

清除目前選擇。


void edit(hide_focus: bool = false) 🔗

允許進入編輯模式,無論 LineEdit 是否獲得焦點。如果 hide_focus 為 true,則不會顯示焦點狀態(參見 Control.grab_focus())。

另見 keep_editing_on_text_submit。


PopupMenu get_menu() const 🔗

返回該 LineEdit 的 PopupMenu。預設情況下,右鍵點選 LineEdit 會顯示該選單。

可以新增自訂功能表專案或移除標準功能表專案。確保你的 ID 不與標準 ID 衝突(請參閱 MenuItems)。例如:

func _ready():
    var menu = get_menu()
    # 在“重做”之後移除所有專案。
    menu.item_count = menu.get_item_index(MENU_REDO) + 1
    # 新增自訂專案。
    menu.add_separator()
    menu.add_item("Insert Date", MENU_MAX + 1)
    # 連接回呼函式。
    menu.id_pressed.connect(_on_item_pressed)

func _on_item_pressed(id):
    if id == MENU_MAX + 1:
        insert_text_at_caret(Time.get_date_string_from_system())

警告:這是一個必需的內部節點,移除和釋放它可能會導致當機。如果希望隱藏它或它的任何子節點,請使用它們的 Window.visible 屬性。


int get_next_composite_character_column(column: int) const 🔗

如果游標位於合成字元的開頭,則回傳該字元末尾所在的正確列。合成字元由多個 Unicode 碼位組合而成(例如修復愛心 ❤️‍🩹 的 Unicode 為 U+2764 U+FE0F U+200D U+1FA79)。如果文字游標位於非合成字元字素的內部,也會回傳正確的列。

注意:請使用 get_next_composite_character_column(get_caret_column()) 在文字游標的位置進行檢查


int get_previous_composite_character_column(column: int) const 🔗

如果游標位於合成字元的末尾,則回傳該字元開頭所在的正確列。合成字元由多個 Unicode 碼位組合而成(例如修復愛心 ❤️‍🩹 的 Unicode 為 U+2764 U+FE0F U+200D U+1FA79)。如果文字游標位於非合成字元字素的內部,也會回傳正確的列。

注意:請使用 get_previous_composite_character_column(get_caret_column()) 在文字游標的位置進行檢查


float get_scroll_offset() const 🔗

返回 caret_column 引起的捲動偏移量,單位為字元數。


String get_selected_text() 🔗

返回選擇內的文字。


int get_selection_from_column() const 🔗

返回選擇的開始列。


int get_selection_to_column() const 🔗

返回選擇結束列。


bool has_ime_text() const 🔗

如果使用者的輸入法編輯器中存在文字,則回傳 true。


bool has_redo() const 🔗

有“重做”動作可用時返回 true。


bool has_selection() const 🔗

如果使用者選中了文字,則返回 true。


bool has_undo() const 🔗

有“復原”動作可用時返回 true。


void insert_text_at_caret(text: String) 🔗

在游標處插入文字 text。如果最終值比 max_length 長,則不會發生任何事情。


bool is_editing() const 🔗

回傳 LineEdit 是否處於編輯狀態。


bool is_menu_visible() const 🔗

返回選單是否可見。請使用這個方法來代替 get_menu().visible,可以提高效能(因為避免了選單的建立)。


void menu_option(option: int) 🔗

執行 MenuItems 列舉中定義的給定操作。


void select(from: int = 0, to: int = -1) 🔗

選擇 LineEdit 內介於 from 和 to 之間的字元。預設情況下,from 位於開頭,to 位於結尾。

text = "Welcome"
select() # 將選擇“Welcome”。
select(4) # 將選擇“ome”。
select(2, 5) # 將選擇“lco”。

void select_all() 🔗

選中整個 String。


void unedit() 🔗

允許退出編輯模式,保持焦點。


主題屬性說明

Color caret_color = Color(0.95, 0.95, 0.95, 1) 🔗

LineEdit 的插入符號(文字游標)的顏色。可以設定為完全透明的顏色,從而完全隱藏游標。


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(0, 0, 0, 1) 🔗

LineEdit 文字輪廓的色調。


Color font_placeholder_color = Color(0.875, 0.875, 0.875, 0.6) 🔗

placeholder_text 的字形顏色。


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 🔗

文字的最小水平空間(不包括清除按鈕和內容邊距)。這個值以“M”字元的數量來衡量(即能夠在不捲動的情況下顯示這麼多個“M”字元)。


int outline_size = 0 🔗

文字輪廓的大小。

注意:如果使用啟用了 FontFile.multichannel_signed_distance_field 的字形,其 FontFile.msdf_pixel_range 必須至少設定為 outline_size 的兩倍,輪廓渲染才能看起來正確。否則,輪廓可能會比預期的更早被切斷。


Font font 🔗

文字使用的字形。


int font_size 🔗

該 LineEdit 文字的字形大小。


Texture2D clear 🔗

“清除”按鈕的紋理。見 clear_button_enabled。


StyleBox focus 🔗

LineEdit 擁有 GUI 焦點時使用的背景。focus StyleBox 顯示在基礎 StyleBox 之上,所以應該使用部分透明的 StyleBox,確保基礎 StyleBox 仍然可見。代表輪廓或底線的 StyleBox 可以很好地實作這個目的。要停用聚焦的視覺效果,請指定 StyleBoxEmpty 資源。請注意,停用聚焦的視覺效果會影響使用鍵盤/控制器進行導覽的可用性,所以出於可存取性的原因,不建議這樣做。


StyleBox normal 🔗

該 LineEdit 的預設背景。


StyleBox read_only 🔗

該 LineEdit 處於唯讀模式時使用的背景(editable 為 false)。