Module text_input

Module text_input 

Source
Expand description

Text input widget and properties.

The TextInput! widget is an text or parsed value editor that is styleable.

The example below defines 3 text inputs with the FieldStyle!.

use zng::prelude::*;

Stack! {
    zng::text_input::style_fn = style_fn!(|_| zng::text_input::FieldStyle!());
    children = ui_vec![
        TextInput! {
            txt = var(Txt::from("name"));
            max_chars_count = 50;
        },
        TextInput! {
            txt_parse = var(0u32);
            zng::text_input::field_help = "help text";
            // txt_parse_on_stop = true;
        },
        TextInput! {
            txt = var_from("pass");
            obscure_txt = true;
        },
    ];
    direction = StackDirection::top_to_bottom();
    spacing = 5;
}

The first input binds directly to a Txt read-write variable. The second field binds to an u32 read-write variable using the txt_parse property. The third field obscures the text. The FieldStyle! adds data validation adorners to the TextInput!, in the first field a char count is shown, in the second field the field_help or parse errors are shown.

§Full API

See zng_wgt_text_input for the full widget API.

Structs§

DefaultStyle
W Text input default style.
FieldStyle
W Text input style that shows data notes, info, warn and error.
SearchStyle
W Text input style for a search field.
TextInput
W Simple text editor widget.

Functions§

data_notes_adorner_fn
P Adorner property used by FieldStyle to show data info, warn and error.
field_help
P Text shown under a FieldStyle when it has no data notes (no info, warn or error).
field_style_fn
P Extends or replaces the FieldStyle!.
max_chars_count_adorner_fn
P Adorner property used by FieldStyle to show the count/max indicator.
search_style_fn
P Extends or replaces the SearchStyle!.
style_fn
P Extends or replaces the widget style.