Struct TextboxState

Source
pub struct TextboxState {
    pub cursor_pos: usize,
    pub text: String,
    pub hint_text: Option<String>,
    /* private fields */
}

Fields§

§cursor_pos: usize§text: String§hint_text: Option<String>

Implementations§

Source§

impl TextboxState

Source

pub fn handle_events(&mut self, key_code: KeyCode, key_modifiers: KeyModifiers)

Examples found in repository?
examples/demo.rs (line 53)
47    fn handle_events(&mut self, key: KeyEvent) -> std::io::Result<bool> {
48        match (key.code, key.modifiers) {
49            (KeyCode::Esc, _) => return Ok(true),
50            (KeyCode::Tab, _) => { self.focused_textbox = (self.focused_textbox + 1) % 2;  },
51            (key_code, key_modifiers) => {
52                match self.focused_textbox {
53                    0 => self.textbox_state.handle_events(key_code, key_modifiers),
54                    1 => self.textbox2_state.handle_events(key_code, key_modifiers),
55                    _ => {}
56                };
57            }
58        }
59        Ok(false)
60    }

Trait Implementations§

Source§

impl Default for TextboxState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.