Enter one line or several (textarea).
Click, drag or double-click to select, Shift with the arrows to extend; Ctrl / ⌘ with A, C, X, V, Z to select all, copy, cut, paste and undo; input methods are supported, with the composition drawn underlined at the caret.
Installation
Components are distributed as source. Copy it and what it depends on into your project, then change it as you need:
cargo run --release --bin amenui -- add input --to ../my-appFiles copied: src/widgets/input.rs, src/widgets/mod.rs
Usage
use amenui::widgets::{input, textarea};
fn view() -> El<Msg> {
input("i1", &TextEdit::new("林"), "名称", 280.0, 40, Msg::Edit)
}Examples
Empty
fn view() -> El<Msg> {
input("i2", &TextEdit::default(), "搜索…", 280.0, 40, Msg::Edit)
}Several lines
fn view() -> El<Msg> {
textarea("i3", &TextEdit::new("第一行\n第二行"), "备注", 280.0, 3, 400, Msg::Edit)
}API
| Functions | input, textarea |
|---|---|
| Props | key, edit: &TextEdit (text, caret, selection, composition, undo), placeholder, width, (rows,) max characters, msg. |
| Files | src/widgets/input.rs |
| Depends on | base |
| Response to fronts | nudge (a control: pushed as one piece by fronts, held and condensing at most to Look::legible_cap) |
| Recomposition | never (typing is immediate) |
Keyboard and accessibility
| States | empty with placeholder, focused with caret and selection, composing (underlined), disabled. |
|---|---|
| Keys and messages | msg(TextEdit) with the edited value for every text event; typing never recomposes. |
On the web every control is mirrored into the page as an element with its role and name, so screen readers and the browser's own focus see it (DESIGN.md §1.14).
Recipes: A form