跳到正文

Toggle

可按压的控件,会保留开启或关闭的按下状态。

正在加载交互演示…

#导入

从 quickgui 导入 Toggle。

use quickgui::*;

#用法

Toggle::new(pressed)
    .root().on_click(toggle).child("Pin this item")

#结构

  • Toggle::root
  • Toggle::indicator

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

pub const fn new(pressed: bool) -> Self
is_pressedpub const fn is_pressed(self) -> bool—

Configures is pressed for this part.

pub const fn is_pressed(self) -> bool
查看源码

Toggle::root_with

查看源码
pub fn root_with(self, root: Element) -> Element

Decorate an application-owned root without adding layout or appearance.

Toggle::root

查看源码
pub fn root(self) -> Element

Create the unstyled root part. Use [`Self::root_with`] to supply an existing element.

Toggle::indicator_with

查看源码
pub fn indicator_with(self, indicator: Element) -> Element

Hide an application-owned decorative indicator from the accessible name.

Toggle::indicator

查看源码
pub fn indicator(self) -> Element

Create the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.

pub fn toggle(pressed: bool) -> Element

Create an unstyled controlled toggle-button root. This shorthand is equivalent to `Toggle::new(pressed).root_with(div())`.