Skip to main content

TextFieldScope

Struct TextFieldScope 

Source
pub struct TextFieldScope { /* private fields */ }
Expand description

A TextField and its builder.

Implementations§

Source§

impl TextFieldScope

Source

pub fn text(self, text: impl Into<String>) -> Self

The text the field starts with. Only the start: the field stays uncontrolled, so what the user types is never written back, and a later value here changes nothing on the field that is already there. To show other text, such as another document, give the field a new identity with key, and the new field starts with this text.

Source

pub fn placeholder(self, placeholder: impl Into<String>) -> Self

Source

pub fn enabled(self, enabled: bool) -> Self

Source

pub fn multiline(self, multiline: bool) -> Self

Source

pub fn type_role(self, role: TypeRole) -> Self

The rung of the type ladder the field’s own text is set in.

Source

pub fn font_size(self, sp: f32) -> Self

Explicit font size in sp. Overrides the type role’s size.

Source

pub fn font_weight(self, weight: u16) -> Self

Explicit font weight (e.g. 400, 500, 600, 700). Overrides the type role’s weight.

Source

pub fn line_height(self, sp: f32) -> Self

Explicit line height in sp, or NaN (normal) to use the font’s own metrics. An unset line height (0 or never calling this) falls back to the type role’s line height.

Source

pub fn letter_spacing(self, sp: f32) -> Self

Explicit letter spacing in sp.

Source

pub fn color(self, paint: Paint) -> Self

Explicit text colour.

Source

pub fn placeholder_color(self, paint: Paint) -> Self

Explicit placeholder text colour. Sent only when set; absent keeps the design system’s default.

Source

pub fn caret_color(self, paint: Paint) -> Self

Explicit caret colour. Sent only when set; absent keeps the design system’s default.

Source

pub fn font(self, font: FontRefs) -> Self

The fonts to try for the field’s text, in order. Taken only with TypeRole::None.

Source

pub fn font_feature_settings(self, features: &[FontFeature]) -> Self

OpenType features for the typed text and the placeholder, as Text::font_feature_settings takes them. Taken with or without a type role.

Source

pub fn word_break(self, word_break: WordBreak) -> Self

Where a line of the typed text and of the placeholder may break inside a word, as Text::word_break does. CSS word-break.

Source

pub fn overflow_wrap(self, overflow_wrap: OverflowWrap) -> Self

Whether a token too long for its line may break inside itself, in the typed text and the placeholder, as Text::overflow_wrap does. CSS overflow-wrap.

Source

pub fn on_value_change(self, handler: impl FnMut(String) + 'static) -> Self

Source

pub fn on_submit(self, handler: impl FnMut(String) + 'static) -> Self

Source

pub fn on_focus_gained(self, handler: impl FnMut() + 'static) -> Self

Source

pub fn on_focus_lost(self, handler: impl FnMut() + 'static) -> Self

Source

pub fn on_key_down(self, handler: impl FnMut(KeyEvent) + 'static) -> Self

Sees each key the field is pressed with; calling consume on the event keeps the field from acting on it.

Source

pub fn on_key_up(self, handler: impl FnMut(KeyEvent) + 'static) -> Self

Sees each key released while the field holds focus.

Source

pub fn on_composition_change(self, handler: impl FnMut(bool) + 'static) -> Self

Reports when an input method begins or ends an active composition in the field.

Source

pub fn focus_handle(self, handle: &FocusHandle) -> Self

Binds handle to this field, so handle.request() puts keyboard focus here.

Source

pub fn on_motion_finished( self, handler: impl FnMut(MotionFinished) + 'static, ) -> Self

Runs once when the field’s size motion comes to rest, with the size it settled at in dp. The field needs Modifier::motion for its size to move; without it nothing is reported. A run interrupted by a newer size is not reported, only the one that settles.

Source

pub fn bare(self) -> Self

Draws the field without the design system’s frame: no fill, line, underline, corner clip, inner padding, minimum height or focus line. Text, placeholder, caret, selection and input methods stay as they are. For a field that sits inside a box which already draws its own frame, so the frame is not drawn twice. A background or border given on the node is still drawn.

Source§

impl TextFieldScope

Source

pub fn modifier(self, modifier: Modifier) -> Self

What sits around it. Compose’s modifier parameter.

Trait Implementations§

Source§

impl Drop for TextFieldScope

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.