pub struct Input<'a> { /* private fields */ }Expand description
A decorated input (see the module).
Implementations§
Source§impl<'a> Input<'a>
impl<'a> Input<'a>
Sourcepub fn text(value: &'a mut String, label: &str) -> Self
pub fn text(value: &'a mut String, label: &str) -> Self
A text field named label (for assistive technologies and
agents; the label itself is drawn by the form around it).
Need (input): a single-line text field. Need (input): a text field with a placeholder.
Sourcepub fn masked(value: &'a mut String, label: &str) -> Self
pub fn masked(value: &'a mut String, label: &str) -> Self
A masked text field (a password, a token, a key): every character a bullet, nothing to copy, and its value never given to assistive technologies or agents, only its name.
Need (input): a password field. Need (input): a masked field for a secret (token, API key).
Sourcepub fn multiline(value: &'a mut String, label: &str) -> Self
pub fn multiline(value: &'a mut String, label: &str) -> Self
A multi-line text field: rows lines tall, growing
with its text up to max_rows, then scrolling;
Enter starts a new line, Ctrl+Enter submits (see
submit_on_enter).
Need (input): a multi-line text field (a description, notes). Need (input): a text area that grows with its text.
Sourcepub fn rows(self, rows: usize) -> Self
pub fn rows(self, rows: usize) -> Self
A multi-line field’s height when its text is short, in lines (at
least one; 2 by default). Raises max_rows to
it if needed. Nothing on a single-line field.
Sourcepub fn max_rows(self, max_rows: usize) -> Self
pub fn max_rows(self, max_rows: usize) -> Self
The most lines a multi-line field grows to before it scrolls (8 by
default; never under rows). Nothing on a
single-line field.
Sourcepub fn submit_on_enter(self, on: bool) -> Self
pub fn submit_on_enter(self, on: bool) -> Self
In a multi-line field, Enter submits and Shift+Enter starts a new line (a chat box); by default Enter starts a new line and Ctrl+Enter submits. Nothing on a single-line field.
Sourcepub fn search(value: &'a mut String, label: &str) -> Self
pub fn search(value: &'a mut String, label: &str) -> Self
A search field: a magnifier before the query, clearable.
Need (input): a search field. Need (input): a filter box.
Sourcepub fn path(value: &'a mut String, label: &str) -> Self
pub fn path(value: &'a mut String, label: &str) -> Self
A path field.
Need (input): a file or folder path field.
Sourcepub fn number(value: &'a mut f64, label: &str) -> Self
pub fn number(value: &'a mut f64, label: &str) -> Self
A number field: a number or an expression (x * 2, 1,5),
committed when it loses the focus.
Need (input): a number field with a unit.
Sourcepub fn placeholder(self, text: &str) -> Self
pub fn placeholder(self, text: &str) -> Self
The hint shown while the field is empty.
Sourcepub fn leading_icon(self, icon: impl Into<IconRef>) -> Self
pub fn leading_icon(self, icon: impl Into<IconRef>) -> Self
An icon before the value, by value or by name (an unknown name is reported and drawn as the placeholder).
Sourcepub fn trailing_icon(self, icon: impl Into<IconRef>) -> Self
pub fn trailing_icon(self, icon: impl Into<IconRef>) -> Self
An icon after the value, by value or by name.
Sourcepub fn clearable(self, on: bool) -> Self
pub fn clearable(self, on: bool) -> Self
Shows the clear ✕ while there is a value (on by default for a search field). A number field has none: its reset is the default.
A button joined to the field’s end; its click is
InputOutput::button.
Sourcepub fn choices<S: Into<String>>(
self,
items: impl IntoIterator<Item = S>,
) -> Self
pub fn choices<S: Into<String>>( self, items: impl IntoIterator<Item = S>, ) -> Self
A dropdown chevron offering these values.
Sourcepub fn state(self, state: FieldState) -> Self
pub fn state(self, state: FieldState) -> Self
The field’s state: modified, required, invalid, disabled (with a reason), read-only, pending.
Sourcepub fn tab(self, stop: TabStop) -> Self
pub fn tab(self, stop: TabStop) -> Self
Its place in the Tab order of the scope it is drawn in.
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Its width, attached buttons included (the available width by default).
Sourcepub fn cell(self, size: Vec2) -> Self
pub fn cell(self, size: Vec2) -> Self
A compact cell: exactly size (attached buttons included), for
a slot of a dense layout (a HUD part, a table cell, a property
row), its padding the small step (space.xs) instead of
space.s, and none of the room an input otherwise keeps for its
text (four rows’ height). Everything else is the input’s: the
placeholder, the slots, the state, the keys and the name.
Sourcepub fn id_salt(self, salt: impl Hash + Debug) -> Self
pub fn id_salt(self, salt: impl Hash + Debug) -> Self
Distinguishes inputs with the same label in one place.
Sourcepub fn default_value(self, value: &str) -> Self
pub fn default_value(self, value: &str) -> Self
The value “reset to default” puts back, as text (for a number,
its text: "0").
Sourcepub fn precision(self, decimals: usize) -> Self
pub fn precision(self, decimals: usize) -> Self
A number field’s decimals when it is not being typed in.
Sourcepub fn show(self, ui: &mut Ui) -> InputOutput
pub fn show(self, ui: &mut Ui) -> InputOutput
Draws the input; says what it did.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Input<'a>
impl<'a> RefUnwindSafe for Input<'a>
impl<'a> Send for Input<'a>
impl<'a> Sync for Input<'a>
impl<'a> Unpin for Input<'a>
impl<'a> UnsafeUnpin for Input<'a>
impl<'a> !UnwindSafe for Input<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more