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

文档 / 组件 / 输入 / 输入框 文档 / 组件 / 输入 /

输入框

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

输入一行或多行文字(textarea)。

可以点、拖动、双击选择,Shift 加方向键扩展选区;Ctrl / ⌘ 加 A、C、X、V、Z 全选、复制、剪切、粘贴、撤销;支持输入法,正在组字的部分画在插入点上,带下划线。

由 amenui 绘制打开 ↗

安装

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

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

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

用法

rust
use amenui::widgets::{input, textarea};

fn view() -> El<Msg> {
    input("i1", &TextEdit::new("林"), "名称", 280.0, 40, Msg::Edit)
}

示例

空的

rust
fn view() -> El<Msg> {
    input("i2", &TextEdit::default(), "搜索…", 280.0, 40, Msg::Edit)
}

多行

rust
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)。

配方: 表单