LineEdit
用于输入单行文本的控件。有关能够处理多行文本的控件,请参见 TextEdit。
enabled
Section titled “enabled”booldefault: true
当为 false 时,无法输入任何内容。
font-size
Section titled “font-size”lengthdefault: 0px
输入文本的字体大小
font-family
Section titled “font-family”stringdefault: ""
输入文本的字体系列
font-italic
Section titled “font-italic”booldefault: false
输入文本的字体斜体状态
has-focus
Section titled “has-focus”bool(out)
当单行编辑器当前具有焦点时设置为 true
horizontal-alignment
Section titled “horizontal-alignment”enum TextHorizontalAlignmentdefault: left
文本的水平对齐方式。
input-method-hints
Section titled “input-method-hints”struct InputMethodHintsdefault: a struct with all default values
平台输入法(例如软键盘)的提示,例如用于配置自动大写。 输入法可能会考虑这些提示,也可能忽略它们。
LineEdit { input-method-hints: { capitalization: CapitalizationMode.words };}input-type
Section titled “input-type”placeholder-text
Section titled “placeholder-text”stringdefault: ""
编辑字段中没有文本时显示的占位文本
read-only
Section titled “read-only”booldefault: false
设置为 true 时,通过键盘和鼠标进行的文本编辑被禁用,但 仍可选择文本,也可通过编程方式编辑文本。
focus()
Section titled “focus()”调用此函数以聚焦 LineEdit 并使其接收后续键盘事件。
clear-focus()
Section titled “clear-focus()”调用此函数以从此 LineEdit 移除键盘焦点(如果它当前具有焦点)。另请参见 FocusHandling。
set-selection-offsets(anchor: int, focus: int)
Section titled “set-selection-offsets(anchor: int, focus: int)”选择两个 UTF-8 偏移之间的文本:anchor 是保持不动的选择端,focus 是光标移动到的端,因此 focus 可以先于 anchor 以反向选择。
为两者传递相同的值可将文本光标放置在该偏移处而不选择任何内容。
select-all()
Section titled “select-all()”选择所有文本。
clear-selection()
Section titled “clear-selection()”清除选择。
无论 read-only 和 enabled 属性如何,此函数都会生效。
copy()
Section titled “copy()”将选中的文本复制到剪贴板。
将选中的文本复制到剪贴板并从可编辑区域中移除。
无论 read-only 和 enabled 属性如何,此函数都会生效。
paste()
Section titled “paste()”将剪贴板的文本内容粘贴到光标位置。
无论 read-only 和 enabled 属性如何,此函数都会生效。
undo()
Section titled “undo()”撤销上次文本操作。
无论 read-only 和 enabled 属性如何,此函数都会生效。
redo()
Section titled “redo()”重做上次撤销的文本操作。
无论 read-only 和 enabled 属性如何,此函数都会生效。
accepted(string)
Section titled “accepted(string)”当按下回车键时调用。
LineEdit { accepted(text) => { debug("Accepted: ", text); }}edited(string)
Section titled “edited(string)”当文本因用户修改而发生变化时发出
LineEdit { edited(text) => { debug("Text edited: ", text); }}key-pressed(KeyEvent) -> EventResult
Section titled “key-pressed(KeyEvent) -> EventResult”当按键被按下时调用,参数是一个 KeyEvent 结构体。使用此回调在 LineEdit
处理键之前处理按键。返回 accept 表示你已处理该事件,或返回
reject 让 LineEdit 处理它。
key-released(KeyEvent) -> EventResult
Section titled “key-released(KeyEvent) -> EventResult”当按键被释放时调用,参数是一个 KeyEvent 结构体。使用此回调在 LineEdit
处理键之前处理按键。返回 accept 表示你已处理该事件,或返回
reject 让 LineEdit 处理它。
© 2026 SixtyFPS GmbH