Button
可访问的按压目标,可自行设置样式并组合文本或其他内容。
正在加载交互演示…
button()
.h(40.0)
.px(16.0)
.bg(Color::rgb8(37, 99, 235))
.text_color(Color::WHITE)
.rounded(8.0)
.hover(|style| style.bg(Color::rgb8(59, 130, 246)))
.on_click(save)
.child("Save changes")#导入
从 quickgui 导入 button。
use quickgui::*;#用法
button()
.h(40.0)
.px(16.0)
.bg(Color::rgb8(37, 99, 235))
.text_color(Color::WHITE)
.rounded(8.0)
.hover(|style| style.bg(Color::rgb8(59, 130, 246)))
.on_click(save)
.child("Save changes")#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
button
查看源码pub fn button() -> ElementCreate a semantic, keyboard-focusable button container.
on_clickpub fn on_click<V>(mut self, listener: crate::ClickListener<V>) -> Self—
Attach a listener registered by [`crate::ViewContext::listener`].
pub fn on_click<V>(mut self, listener: crate::ClickListener<V>) -> Self查看源码disabledpub fn disabled(mut self, disabled: bool) -> Self—
childpub fn child(mut self, child: impl IntoElement) -> Self—
hpub fn h(mut self, height: f32) -> Self—
pxpub fn px(mut self, value: f32) -> Self—
bgpub fn bg(mut self, color: Color) -> Self—
roundedpub fn rounded(mut self, radius: f32) -> Self—
hoverpub fn hover(mut self, style: impl FnOnce(ElementStateStyle) -> ElementStateStyle) -> Self—
Configures hover for this part.
pub fn hover(mut self, style: impl FnOnce(ElementStateStyle) -> ElementStateStyle) -> Self查看源码