pub struct Input { /* private fields */ }Expand description
A single-line text input widget.
Supports cursor movement (Home/End/Left/Right), Backspace/Delete,
placeholder text, focus styling, and an optional submit callback.
Use Input::text to retrieve the entered value.
Implementations§
Source§impl Input
impl Input
pub fn placeholder(self, text: impl Into<Text>) -> Self
pub fn style(self, style: Style) -> Self
pub fn focus_style(self, style: Style) -> Self
Sourcepub fn on_submit(self, f: impl FnMut(&str) + 'static) -> Self
pub fn on_submit(self, f: impl FnMut(&str) + 'static) -> Self
Sets a callback invoked when Enter is pressed.
Receives the current text as a &str.
pub fn text(&self) -> &str
Trait Implementations§
Source§impl Component for Input
impl Component for Input
Source§fn measure(&self, _constraint: Constraint, _cx: &mut MeasureCx) -> Size
fn measure(&self, _constraint: Constraint, _cx: &mut MeasureCx) -> Size
测量组件在给定约束下的自适应尺寸 Read more
Source§fn layout(&mut self, _rect: Rect, _cx: &mut LayoutCx<'_>)
fn layout(&mut self, _rect: Rect, _cx: &mut LayoutCx<'_>)
布局回调——组件在此计算子节点 rect 并调用 child.layout() Read more
Source§fn for_each_child(&self, _f: &mut dyn FnMut(&Node))
fn for_each_child(&self, _f: &mut dyn FnMut(&Node))
遍历子节点(为焦点系统等提供统一的树遍历接口)
Source§fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))
fn for_each_child_mut(&mut self, _f: &mut dyn FnMut(&mut Node))
遍历子节点(可变版本)
Auto Trait Implementations§
impl Freeze for Input
impl !RefUnwindSafe for Input
impl !Send for Input
impl !Sync for Input
impl Unpin for Input
impl UnsafeUnpin for Input
impl !UnwindSafe for Input
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