在页面之上显示需要处理的内容。
关闭之前,页面的其余部分不响应操作;Esc 或关闭按钮关闭它。
安装
组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:
cargo run --release --bin amenui -- add dialog --to ../my-app拷贝的文件: src/widgets/dialog.rs, src/widgets/mod.rs, src/widgets/button.rs
用法
use amenui::widgets::{dialog};
fn view() -> El<Msg> {
col().gap(8.0).child(button("rename", "重命名…", Msg::Nothing)).child(dialog("d1", false, "重命名", 320.0, 0.35, Msg::Nothing, text("新的名字", 14.0, Paint::TEXT)))
}接口
| 函数 | dialog |
|---|---|
| 参数 | key, open, title, width, beneath (looseness of the page under it, about 0.35), close, body. |
| 文件 | src/widgets/dialog.rs |
| 依赖 | base, button |
| 对波前的响应 | 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 |
键盘与无障碍
| 状态 | open or nothing; focus inside while open. |
|---|---|
| 键盘与消息 | close on Esc or 关闭; whatever its body sends. |
在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。
配方: 对话框