输入一行或多行文字(textarea)。
可以点、拖动、双击选择,Shift 加方向键扩展选区;Ctrl / ⌘ 加 A、C、X、V、Z 全选、复制、剪切、粘贴、撤销;支持输入法,正在组字的部分画在插入点上,带下划线。
安装
组件以源码分发。把它和它依赖的文件拷进你的项目,再按需要改:
cargo run --release --bin amenui -- add input --to ../my-app拷贝的文件: src/widgets/input.rs, src/widgets/mod.rs
用法
use amenui::widgets::{input, textarea};
fn view() -> El<Msg> {
input("i1", &TextEdit::new("林"), "名称", 280.0, 40, Msg::Edit)
}示例
空的
fn view() -> El<Msg> {
input("i2", &TextEdit::default(), "搜索…", 280.0, 40, Msg::Edit)
}多行
fn view() -> El<Msg> {
textarea("i3", &TextEdit::new("第一行\n第二行"), "备注", 280.0, 3, 400, Msg::Edit)
}接口
| 函数 | input, textarea |
|---|---|
| 参数 | key, edit: &TextEdit (text, caret, selection, composition, undo), placeholder, width, (rows,) max characters, msg. |
| 文件 | src/widgets/input.rs |
| 依赖 | base |
| 对波前的响应 | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| 重组 | never (typing is immediate) |
键盘与无障碍
| 状态 | empty with placeholder, focused with caret and selection, composing (underlined), disabled. |
|---|---|
| 键盘与消息 | msg(TextEdit) with the edited value for every text event; typing never recomposes. |
在网页上,每个控件都在页面里有一个带角色和名字的镜像元素,读屏软件和浏览器自己的焦点都看得到它(DESIGN.md §1.14)。
配方: 表单