pub struct TextInput { /* private fields */ }Expand description
A single line of editable text. Reports ActionKind::Changed after every edit and
ActionKind::Submitted on Enter.
Clicks place the caret (two select a word, three everything), dragging selects, the arrow keys and Home/End move (with Shift: select; with Ctrl, or Cmd on macOS: by word), Backspace and Delete remove characters or words, and input methods compose in place.
Implementations§
Source§impl TextInput
impl TextInput
Sourcepub fn with_placeholder(self, placeholder: impl Into<String>) -> Self
pub fn with_placeholder(self, placeholder: impl Into<String>) -> Self
The input showing placeholder, dimmed, while it is empty.
Sourcepub fn set_text(
&mut self,
cx: &mut EventCx<'_>,
text: impl Into<String>,
) -> Result<(), ParagraphError>
pub fn set_text( &mut self, cx: &mut EventCx<'_>, text: impl Into<String>, ) -> Result<(), ParagraphError>
Replaces the text, the caret at its end.
§Errors
ParagraphError::UnreadableFont if a font for text cannot be read; nothing
changes.
Trait Implementations§
Source§impl Widget for TextInput
impl Widget for TextInput
Source§fn accessibility(&self, _: &PaintCx<'_>, node: &mut AccessNode)
fn accessibility(&self, _: &PaintCx<'_>, node: &mut AccessNode)
Describes the widget to assistive technology: fills
node, which starts as a
Role::Group with the widget’s rectangle. Called only while
assistive technology is listening; it may allocate.Source§fn access_action(
&mut self,
cx: &mut EventCx<'_>,
request: &AccessRequest<'_>,
) -> Handled
fn access_action( &mut self, cx: &mut EventCx<'_>, request: &AccessRequest<'_>, ) -> Handled
Does what assistive technology asks (only actions the widget’s node lists are asked
of it). Focus and scrolling into view are done for every widget; a request the widget
does not handle goes on to its parent if it is a scroll.
Source§fn measure(&mut self, cx: &mut LayoutCx<'_>, _: Constraints) -> Size
fn measure(&mut self, cx: &mut LayoutCx<'_>, _: Constraints) -> Size
The size the widget wants within
constraints, for a widget without children (one
with children is sized by its style and its children). Physical pixels.Source§fn layout(&mut self, cx: &mut LayoutCx<'_>, size: Size)
fn layout(&mut self, cx: &mut LayoutCx<'_>, size: Size)
Layout decided the widget’s size: re-wrap text or recompute anything that depends on
it. Called after every layout pass that changed the size.
Source§fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
fn paint(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
Paints the widget below its children.
Source§fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled
fn event(&mut self, cx: &mut EventCx<'_>, event: &Event<'_>) -> Handled
Handles
event. An event the widget does not handle goes on to its parent.Source§fn accepts_focus(&self) -> bool
fn accepts_focus(&self) -> bool
Whether the widget takes keyboard focus, by click or by Tab.
Source§fn paint_over(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
fn paint_over(&mut self, cx: &PaintCx<'_>, canvas: &mut Canvas<'_>)
Paints the widget over its children: scroll bars, focus rings, overlays.
Source§fn focus_on_press(&self) -> bool
fn focus_on_press(&self) -> bool
Whether a press on the widget, or on a widget inside it that takes no focus, focuses
it (if it accepts focus). A container reachable by Tab, such
as a dock’s tab list, says no, so clicks on its contents do not focus it; it can still
ask for focus itself.
Auto Trait Implementations§
impl !RefUnwindSafe for TextInput
impl !UnwindSafe for TextInput
impl Freeze for TextInput
impl Send for TextInput
impl Sync for TextInput
impl Unpin for TextInput
impl UnsafeUnpin for TextInput
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
Mutably borrows from an owned value. Read more