Skip to main content

Module input

Module input 

Source
Expand description

A single-line editable text control.

TextInput is a view rather than a RenderOnce builder, because editing carries state that outlives a frame: the caret, the selection, the in-progress input method composition, and the horizontal scroll position. Callers own the entity and read TextInput::value from it.

let input = cx.new(|cx| {
    TextInput::new("settings.token", window, cx)
        .placeholder("sk-...")
        .secret(true)
});
cx.subscribe(&input, |_host, input, event, cx| {
    if let TextInputEvent::Submit = event {
        let _typed = input.read(cx).value().to_string();
    }
})
.detach();

Structs§

Backspace
Cancel
Copy
Cut
Delete
DeleteToLineStart
DeleteWordLeft
DeleteWordRight
Left
LineEnd
LineStart
Paste
Right
SelectAll
SelectLeft
SelectRight
SelectToLineEnd
SelectToLineStart
SelectWordLeft
SelectWordRight
ShowCharacterPalette
Submit
TextInput
One line of editable text.
WordLeft
WordRight

Enums§

TextInputEvent
What an input reports to its owner.

Constants§

KEY_CONTEXT
The key context every input publishes, so a host can layer its own bindings on top without re-declaring these.