Expand description
Driving a single-line text input (widget::text_box()) from the raw UI
events a Yog screen receives — click:X:Y, drag:X:Y, release:X:Y,
key:KEY:MODS and char:CODEPOINT — like ScrollState
does for scroll views.
ⓘ
static SEARCH: Mutex<TextBoxState> = Mutex::new(TextBoxState::new());
// render: feed the text, caret and focus into the tree
SEARCH.lock().unwrap().apply(root.find_mut("search").unwrap());
// events: with the last frame's layout node of "search"; return `true`
// from the `register_ui` handler when it's consumed, so Esc unfocuses
// the box instead of closing the screen
match SEARCH.lock().unwrap().handle(event, node) {
TextBoxEvent::Ignored => { /* not for the box: buttons etc. */ }
TextBoxEvent::Changed => { /* re-filter */ }
TextBoxEvent::Submitted => { /* Enter */ }
TextBoxEvent::Handled => {}
}Structs§
- Text
BoxState - Text, caret, selection and focus of one text box.
Enums§
- Text
BoxEvent - What
TextBoxState::handledid with an event.