zng/
text_input.rs

1#![cfg(feature = "text_input")]
2
3//! Text input widget and properties.
4//!
5//! The [`TextInput!`](struct@TextInput) widget is an text or parsed value editor that is styleable.
6//!
7//! The example below defines 3 text inputs with the [`FieldStyle!`](struct@FieldStyle).
8//!
9//! ```
10//! use zng::prelude::*;
11//! # let _scope = APP.defaults();
12//!
13//! # let _ =
14//! Stack! {
15//!     zng::text_input::style_fn = style_fn!(|_| zng::text_input::FieldStyle!());
16//!     children = ui_vec![
17//!         TextInput! {
18//!             txt = var(Txt::from("name"));
19//!             max_chars_count = 50;
20//!         },
21//!         TextInput! {
22//!             txt_parse = var(0u32);
23//!             zng::text_input::field_help = "help text";
24//!             // txt_parse_on_stop = true;
25//!         },
26//!         TextInput! {
27//!             txt = var_from("pass");
28//!             obscure_txt = true;
29//!         },
30//!     ];
31//!     direction = StackDirection::top_to_bottom();
32//!     spacing = 5;
33//! }
34//! # ;
35//! ```
36//!
37//! The first input binds directly to a `Txt` read-write variable. The second field binds to an `u32` read-write variable using the
38//! [`txt_parse`](struct@TextInput#method.txt_parse) property. The third field obscures the text. The `FieldStyle!` adds data validation
39//! adorners to the `TextInput!`, in the first field a char count is shown, in the second field the [`field_help`](fn@field_help)
40//! or parse errors are shown.
41//!
42//! # Full API
43//!
44//! See [`zng_wgt_text_input`] for the full widget API.
45
46pub use zng_wgt_text_input::{
47    DefaultStyle, FieldStyle, SearchStyle, TextInput, data_notes_adorner_fn, field_help, max_chars_count_adorner_fn, style_fn,
48};