实时演示下面的一行等宽小字:印出驱动它的真实参数(从同一些字段读出来,不是手写的),每个参数也是一个能改的数字控件。
El::caption_params 把它放在演示下面。
安装
组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:
cargo run --release --bin amenui -- add caption --to ../my-app拷贝的文件: src/widgets/caption.rs, src/widgets/mod.rs, src/widgets/number.rs
用法
use amenui::widgets::{caption};
fn view() -> El<Msg> {
let (w, r) = (120.0_f32, 8.0_f32);
let spec = Spec { min: 0.0, max: 400.0, step: 1.0, decimals: 0, unit: "px" };
let params = [CaptionParam::new("width", w, spec), CaptionParam::new("radius", r, spec)];
space(w, 40.0).radius(r).fill(Paint::ACCENT).key("cap1/demo")
.caption_params("cap1", format!("rect(w={w:.0}, r={r:.0})"), ¶ms, Msg::Num)
}接口
| 函数 | caption |
|---|---|
| 参数 | key, formula (the line, written from the same fields the demo reads), params (CaptionParam: name, value, spec, draft), msg. |
| 文件 | src/widgets/caption.rs |
| 依赖 | base, number |
| 对波前的响应 | 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 |
键盘与无障碍
| 状态 | rest; a number being typed (see number); a changed value recomposes its digits. |
|---|---|
| 键盘与消息 | msg(i, Edit) from parameter i's control. |
在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。