其他类型
keysdefault: empty keys
keys 表示一个键与修饰键列表的组合。 这是用于检测 KeyEvent 是否应触发给定按键绑定的原始类型。
Slint 中的按键绑定基于逻辑键——键在当前键盘布局上产生的字符——而不是键在键盘上的物理位置。 详情请参见 按键绑定。
在 Rust 中,keys 类型的属性或结构体字段映射到 slint::Keys。
在 C++ 中,keys 类型的属性或结构体字段映射到 slint::Keys。
在 JavaScript 中,keys 类型的属性或结构体字段映射到 Keys 类。
在 Python 中,keys 类型的属性或结构体字段映射到 Keys。
keys 值具有以下成员函数:
to-string() -> string
Section titled “to-string() -> string”返回键组合的平台原生描述。
export component KeysToString inherits FocusScope { undo := KeyBinding { keys: @keys(Control + Z); activated => { debug("UNDO") } }
Text { text: "Press \{undo.keys.to-string()} to undo!"; // Results in "Press ⌘Z to undo!" on macOS // Results in "Press Ctrl+Z to undo!" on other platforms }}easing
Section titled “easing”easingdefault: linear
easing 类型允许为动画定义缓动曲线。
要指定缓动曲线,请使用 Easing 命名空间中的值。例如可以使用 Easing.ease-out 或 Easing.ease-in-quad。该命名空间包含以下名称(可视化参考见 easings.net):
linearease-in-quadease-out-quadease-in-out-quadeaseease-inease-outease-in-outease-in-quartease-out-quartease-in-out-quartease-in-quintease-out-quintease-in-out-quintease-in-expoease-out-expoease-in-out-expoease-in-sineease-out-sineease-in-out-sineease-in-backease-out-backease-in-out-backease-in-circease-out-circease-in-out-circease-in-elasticease-out-elasticease-in-out-elasticease-in-bounceease-out-bounceease-in-out-bouncecubic-bezier(a, b, c, d),与 CSS 中相同spring(bounce),如 弹簧动画 中所定义
此外,在 easing 类型的表达式中,这些名称可以直接使用。
struct AnimationData { curve: easing,}
component Custom inherits Rectangle { property<AnimationData> animation: { // Using the Easing namespace. curve: Easing.ease-in-circ, };
animate x { // In easing expressions the names are available via global scope. easing: ease-out-bounce; }}data-transfer
Section titled “data-transfer”data-transferdefault: an empty data-transfer
data-transfer 值是拖放和剪贴板操作携带的负载。
它抽象了各平台支持的文件类型传输机制。
它可以同时携带纯文本、图像和本地文件路径列表。
该类型在 Slint 代码中是不透明的:
构造一个 data-transfer 值,并通过宿主语言实现的回调读取其内容。
端到端示例参见 DragAndDrop。
MouseCursor
Section titled “MouseCursor”MouseCursordefault: default
MouseCursor 类型用于 TouchArea 元素。
通过指定名称将其设置为内置形状之一:
TouchArea { mouse-cursor: ew-resize;}
TouchArea { mouse-cursor: MouseCursor.ew-resize;}The following built-in mouse cursor shapes are available through the
MouseCursor namespace. The upstream Slint documentation generator emits this
table; this port does not ship the generator, so the table below is a
hand-maintained stub.
| Cursor | Description |
|---|---|
MouseCursor.default |
The platform default cursor |
MouseCursor.none |
Hide the cursor |
MouseCursor.help |
Help / question mark |
MouseCursor.pointer |
Pointing hand |
MouseCursor.progress |
Busy, still interactive |
MouseCursor.wait |
Busy |
MouseCursor.crosshair |
Crosshair |
MouseCursor.text |
Text selection |
MouseCursor.move |
Move |
MouseCursor.grab |
Grab |
MouseCursor.grabbing |
Grabbing |
MouseCursor.n-resize … MouseCursor.nwse-resize |
Edge and corner resize cursors |
© 2026 SixtyFPS GmbH