Toggle
可按压的控件,会保留开启或关闭的按下状态。
正在加载交互演示…
Toggle::new(pressed)
.root().on_click(toggle).child("Pin this item")#导入
从 quickgui 导入 Toggle。
use quickgui::*;#用法
Toggle::new(pressed)
.root().on_click(toggle).child("Pin this item")#结构
Toggle::rootToggle::indicator
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
Toggle
查看源码pub const fn new(pressed: bool) -> Selfis_pressedpub const fn is_pressed(self) -> bool—
Toggle::root_with
查看源码pub fn root_with(self, root: Element) -> ElementDecorate an application-owned root without adding layout or appearance.
Toggle::root
查看源码pub fn root(self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Toggle::indicator_with
查看源码pub fn indicator_with(self, indicator: Element) -> ElementHide an application-owned decorative indicator from the accessible name.
Toggle::indicator
查看源码pub fn indicator(self) -> ElementCreate the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.
toggle
查看源码pub fn toggle(pressed: bool) -> ElementCreate an unstyled controlled toggle-button root. This shorthand is equivalent to `Toggle::new(pressed).root_with(div())`.
