Skip to main content

TextInput

Struct TextInput 

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

One line of editable text.

Build one with text_input. The input keeps the editor and the glyph runs of its current text, and rebuilds the runs only when the editor laid its text out again, the node moved or the resolved text color changed.

Trait Implementations§

Source§

impl Widget for TextInput

Source§

fn semantics(&self) -> Option<Semantics>

Reports the field’s placeholder as the accessible name and its text as the accessible value.

An input with no placeholder reports no name, which leaves the announcement to the field’s surroundings.

Source§

fn measure(&mut self, input: MeasureInput) -> Option<Size>

Returns the size of one line of text.

Offered space is filled on the x axis, which is what an input field conventionally does, and the intrinsic width is zero, so a field that is not stretched by its parent needs a width or a grow factor. The height is one line of the input’s style. Neither depends on the text, so an edit repaints the input without laying it out again.

That height also rides on the min-height style the constructor sets, because the layout engine measures childless nodes only and the input always carries its caret child.

Source§

fn paint(&self, cx: &PaintCx<'_>, out: &mut Vec<PaintOp>)

Appends the selection, the underline under a composing preedit, the text or the placeholder, in that order.

The caret is a child node of the input and paints itself after this, so the paint order is selection, then preedit underline, then glyphs, then caret. Painting also records the content box, which the pointer handlers and the next edit read, and places the caret against it. An edit has placed the caret already, so this only moves it when the box itself changed, which lands one frame later like every size-driven change.

§Panics

Panics under the conditions of TextSystem::with, or when the glyph run cache is already borrowed on this thread, which the paint pass cannot do.

Source§

fn ime_area(&self) -> Option<Rect>

Reports the area the input method anchors to while the input holds the focus.

The area is the text the user is editing, which is the preedit while one is being composed and the selection otherwise, in paint coordinates.

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> ErasedDestructor for T
where T: 'static,

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.