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
impl Widget for TextInput
Source§fn semantics(&self) -> Option<Semantics>
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>
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>)
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.