Skip to main content

TextInput

Struct TextInput 

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

A single-line text input widget with cursor and editing support.

Implementations§

Source§

impl TextInput

Source

pub fn new(bounds: Rect) -> Self

Create a new text input widget with the given bounds.

Source

pub const fn with_config(bounds: Rect, config: TextInputConfig) -> Self

Create a new text input widget with custom configuration.

Source

pub fn content(&self) -> &str

Get the current text content.

Source

pub fn set_content(&mut self, content: &str)

Set the content, moving cursor to end.

Source

pub fn clear(&mut self)

Clear the content.

Source

pub const fn is_empty(&self) -> bool

Check if the input is empty.

Source

pub const fn set_focused(&mut self, focused: bool)

Set focus state.

Source

pub const fn is_focused(&self) -> bool

Check if focused.

Source

pub const fn tick(&mut self)

Advance frame for cursor blink animation.

Trait Implementations§

Source§

impl Debug for TextInput

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Widget for TextInput

Source§

fn bounds(&self) -> Rect

Get the current bounds of this widget.
Source§

fn set_bounds(&mut self, bounds: Rect)

Set the bounds of this widget. Read more
Source§

fn render(&self, buffer: &mut Buffer)

Render this widget to the given buffer. Read more
Source§

fn handle_input(&mut self, event: &InputEvent) -> bool

Handle an input event. Read more
Source§

fn needs_redraw(&self) -> bool

Check if this widget needs to be redrawn.
Source§

fn clear_redraw(&mut self)

Clear the redraw flag after rendering.

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> 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.