pub struct Input { /* private fields */ }Expand description
A single-line editable text field bound to a RwSignal<String>. A base primitive: unstyled (no
border or background — wrap it in a box for the look) and keyboard-driven. It requests focus on
tap and, while focused, edits the bound signal from key events, drawing a caret at the insertion
point. Selection, clipboard, and IME composition are not yet supported (a single-caret MVP).
Implementations§
Source§impl Input
impl Input
pub fn new( value: RwSignal<String>, layout_style: LayoutStyle, style_fn: impl Fn() -> TextStyle + 'static, ) -> Result<Self, LayoutError>
Sourcepub fn masked(self, bullet: char) -> Self
pub fn masked(self, bullet: char) -> Self
Draws bullet in place of every character, for a password or a PIN.
Rendering only — the bound signal keeps the real text, so a submit handler reads what was typed. Worth having as a property of the field rather than as a caller-side transformation: a caller that masked the signal would have to keep a second copy of the truth, and the caret would measure the wrong string.
Sourcepub fn on_submit(self, f: impl Fn() + 'static) -> Self
pub fn on_submit(self, f: impl Fn() + 'static) -> Self
Runs when Enter is pressed while focused (e.g. submit a form / run a search).
Sourcepub fn placeholder(self, p: impl Into<String>) -> Self
pub fn placeholder(self, p: impl Into<String>) -> Self
A muted hint shown while the value is empty (the field stays tappable/focusable, unlike a swapped-in placeholder widget).
Sourcepub fn autofocus(self) -> Self
pub fn autofocus(self) -> Self
Gives this field keyboard focus as it is built, so the surface it is on is typed into rather than clicked into first.
A field is otherwise focused only by a tap, which is the right default for a form but wrong for the
surface that exists because it wants a keystroke — a search overlay opened on a keybind, a password
prompt. Registration happens in new, so this is a request against an id that is already
in the tab order.
Sourcepub fn request_focus(&self)
pub fn request_focus(&self)
Gives keyboard focus to this field (as a tap would). For programmatic focus after construction — e.g. a
container focusing the field when its tab becomes active. Mirrors TextArea::request_focus.
Sourcepub fn focus_handle(&self) -> FocusHandle
pub fn focus_handle(&self) -> FocusHandle
A Copy focus::FocusHandle to this field, so a caller that has moved it into a container can still
focus it later without keeping a reference to the field itself.