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 (Shift+arrows/Home/End, Ctrl+A) with copy, cut and paste; IME composition is not yet
supported. Drag-to-select waits on click-to-position, which this field does not have either.
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.