Skip to main content

Input

Struct Input 

Source
pub struct Input<'a> { /* private fields */ }
Expand description

A decorated input (see the module).

Implementations§

Source§

impl<'a> Input<'a>

Source

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.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn path(value: &'a mut String, label: &str) -> Self

A path field.

Need (input): a file or folder path field.

Source

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.

Source

pub fn placeholder(self, text: &str) -> Self

The hint shown while the field is empty.

Source

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).

Source

pub fn prefix(self, text: &str) -> Self

A text before the value (https://, #).

Source

pub fn suffix(self, text: &str) -> Self

A text after the value (.jpg).

Source

pub fn unit(self, unit: &str) -> Self

A unit after the value (px, EV).

Source

pub fn trailing_icon(self, icon: impl Into<IconRef>) -> Self

An icon after the value, by value or by name.

Source

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.

Source

pub fn button(self, button: Attached) -> Self

A button joined to the field’s end; its click is InputOutput::button.

Source

pub fn choices<S: Into<String>>( self, items: impl IntoIterator<Item = S>, ) -> Self

A dropdown chevron offering these values.

Source

pub fn state(self, state: FieldState) -> Self

The field’s state: modified, required, invalid, disabled (with a reason), read-only, pending.

Source

pub fn tab(self, stop: TabStop) -> Self

Its place in the Tab order of the scope it is drawn in.

Source

pub fn width(self, width: f32) -> Self

Its width, attached buttons included (the available width by default).

Source

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.

Source

pub fn id_salt(self, salt: impl Hash + Debug) -> Self

Distinguishes inputs with the same label in one place.

Source

pub fn default_value(self, value: &str) -> Self

The value “reset to default” puts back, as text (for a number, its text: "0").

Source

pub fn precision(self, decimals: usize) -> Self

A number field’s decimals when it is not being typed in.

Source

pub fn show(self, ui: &mut Ui) -> InputOutput

Draws the input; says what it did.

Trait Implementations§

Source§

impl Debug for Input<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,