amenui
en·中 github ↗ v0.0.1
01文档 02组件 03实验室 04作品
en·中github ↗
×

文档 / 组件 / 输入 / 选项 文档 / 组件 / 输入 /

选项

04.6
本页内容 ▾
  1. 安装
  2. 用法
  3. 示例
  4. 接口
  5. 键盘与无障碍

从几个互斥的选项中选一个。

由 amenui 绘制打开 ↗

安装

组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:

sh
cargo run --release --bin amenui -- add choice --to ../my-app

拷贝的文件: src/widgets/choice.rs, src/widgets/mod.rs

用法

rust
use amenui::widgets::{choice, segmented};

fn view() -> El<Msg> {
    choice("c1", "大小", &["小", "中", "大"], 1, Msg::Pick)
}

示例

分段

rust
fn view() -> El<Msg> {
    segmented("c2", &["日", "周", "月"], 0, 28.0, Msg::Pick)
}

接口

函数choice, segmented
参数choice(key, label, options, current, msg); segmented(key, options, current, height, msg).
文件src/widgets/choice.rs
依赖base
对波前的响应nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap)
重组keyed labels recompose when their text changes

键盘与无障碍

状态the current option is an ink plate with its label in the ground's colour; segmented is one focus stop, Left / Right move.
键盘与消息msg(i) with the option's index.

在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。