TextEdit
类似于 LineEdit,但可用于输入多行文本
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。
enabled
Section titled “enabled”booldefault: true
当为 false 时,无法输入任何内容。
input-method-hints
Section titled “input-method-hints”struct InputMethodHintsdefault: a struct with all default values
平台输入法(例如软键盘)的提示,例如用于配置自动大写。 输入法可能会考虑这些提示,也可能忽略它们。
TextEdit { input-method-hints: { capitalization: CapitalizationMode.words };}read-only
Section titled “read-only”booldefault: false
设置为 true 时,通过键盘和鼠标进行的文本编辑被禁用,但 仍可选择文本,也可通过编程方式编辑文本。
enum TextWrapdefault: the first enum value
文本换行的方式(默认:word-wrap)。
horizontal-alignment
Section titled “horizontal-alignment”enum TextHorizontalAlignmentdefault: the first enum value
文本的水平对齐方式。
placeholder-text
Section titled “placeholder-text”string(in)default: ""
编辑字段中没有文本时显示的占位文本。
content-width
Section titled “content-width”length(in-out)default: 0px
文本编辑可滚动内容的宽度。此属性以前 称为
viewport-width,该名称仍作为已弃用的 别名可用。
content-height
Section titled “content-height”length(in-out)default: 0px
文本编辑可滚动内容的高度。此属性以前 称为
viewport-height,该名称仍作为已弃用的 别名可用。
content-x
Section titled “content-x”length(in-out)default: 0px
可滚动内容相对于文本编辑的 x 位置。通常 为负值。此属性以前称为
viewport-x, 该名称仍作为已弃用的别名可用。
content-y
Section titled “content-y”length(in-out)default: 0px
可滚动内容相对于文本编辑的 y 位置。通常 为负值。此属性以前称为
viewport-y, 该名称仍作为已弃用的别名可用。
visible-width
Section titled “visible-width”length(out)
文本编辑可见区域的宽度(不包括滚动条)
visible-height
Section titled “visible-height”length(out)
文本编辑可见区域的高度(不包括滚动条)
focus()
Section titled “focus()”调用此函数以聚焦 TextEdit 并使其接收后续键盘事件。
clear-focus()
Section titled “clear-focus()”调用此函数以从此 TextEdit 移除键盘焦点(如果它当前具有焦点)。另请参见 焦点处理。
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 属性如何,此函数都会生效。
edited(string)
Section titled “edited(string)”当文本因用户修改而发生变化时发出
TextEdit { edited(text) => { debug("Edited: ", text); }}key-pressed(KeyEvent) -> EventResult
Section titled “key-pressed(KeyEvent) -> EventResult”当按键被按下时调用,参数是一个 KeyEvent 结构体。使用此回调在 TextEdit
处理键之前处理按键。返回 accept 表示你已处理该事件,或返回
reject 让 TextEdit 处理它。
key-released(KeyEvent) -> EventResult
Section titled “key-released(KeyEvent) -> EventResult”当按键被释放时调用,参数是一个 KeyEvent 结构体。使用此回调在 TextEdit
处理键之前处理按键。返回 accept 表示你已处理该事件,或返回
reject 让 TextEdit 处理它。
© 2026 SixtyFPS GmbH