pub struct TextBoxState { /* private fields */ }Expand description
Text, caret, selection and focus of one text box.
Implementations§
Source§impl TextBoxState
impl TextBoxState
pub const fn new() -> Self
pub fn text(&self) -> &str
Sourcepub fn set_text(&mut self, text: impl Into<String>)
pub fn set_text(&mut self, text: impl Into<String>)
Replaces the text (cut to the max length), caret at the end.
pub fn is_focused(&self) -> bool
Sourcepub fn selection(&self) -> (usize, usize)
pub fn selection(&self) -> (usize, usize)
Selected characters start..end (empty when nothing is selected).
Sourcepub fn select_all(&mut self)
pub fn select_all(&mut self)
Selects all the text.
Sourcepub fn event_name(&self, ev: TextBoxEvent) -> Option<&str>
pub fn event_name(&self, ev: TextBoxEvent) -> Option<&str>
The on_change/on_submit event name the widget declared for a
TextBoxEvent::Changed/TextBoxEvent::Submitted (learned in
Self::apply); None for other results or when it has none.
Sourcepub fn apply(&mut self, w: &mut Widget)
pub fn apply(&mut self, w: &mut Widget)
Writes the state into the text box widget w before layout: text,
caret, selection, scroll, focus. Also picks up the widget’s max
length, padding, font and event names. Does nothing to other kinds.
Sourcepub fn handle(&mut self, event: &str, node: &LayoutNode) -> TextBoxEvent
pub fn handle(&mut self, event: &str, node: &LayoutNode) -> TextBoxEvent
Applies one UI event; node is the box’s laid-out node from the
frame the user saw (UiRoot::find_node).
Sourcepub fn handle_event(
&mut self,
event: &UiEvent<'_>,
node: &LayoutNode,
) -> TextBoxEvent
pub fn handle_event( &mut self, event: &UiEvent<'_>, node: &LayoutNode, ) -> TextBoxEvent
Self::handle for a parsed event.
Trait Implementations§
Source§impl Clone for TextBoxState
impl Clone for TextBoxState
Source§impl Debug for TextBoxState
impl Debug for TextBoxState
Auto Trait Implementations§
impl Freeze for TextBoxState
impl RefUnwindSafe for TextBoxState
impl Send for TextBoxState
impl Sync for TextBoxState
impl Unpin for TextBoxState
impl UnsafeUnpin for TextBoxState
impl UnwindSafe for TextBoxState
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