Struct termit::widget::TextBox

source ·
pub struct TextBox<F, M, A: AppEvent> {
    pub active: bool,
    /* private fields */
}
Expand description

A simplistic single line String editor.

It is suitable for simple use cases such as quick search input.

The cursor is always at the end. Backspace removes the last char.

Clicking on the TextBox activates it, clicking somewhere else deactivates it. You can override this by setting the active property on each update.

No cloning/moving, it will edit the &mut String in the model directly.

The last part of the string that fits is visible (tail).

Fields§

§active: bool

Implementations§

source§

impl<F, M, A: AppEvent> TextBox<F, M, A>where F: Fn(&mut M) -> Option<&mut String>,

source

pub fn new(accessor: F) -> Self

Create a textbox

The accessor specifies how to get to a mutable String reference in the model

Trait Implementations§

source§

impl<F, M, A: AppEvent> AnchorPlacementEnabled for TextBox<F, M, A>

source§

fn place(self) -> PlacedWidget<Self>

Enabling method called by the related AnchorPlaced impl
source§

impl<F, M, A: AppEvent> Widget<M, A> for TextBox<F, M, A>where F: Fn(&mut M) -> Option<&mut String>,

source§

fn update( &mut self, model: &mut M, input: &Event<A>, screen: &mut Screen, painter: &Painter ) -> Window

Do the widget magic. The returned scope must be contained in the painter AND screen scopes
source§

fn update_asserted( &mut self, model: &mut M, input: &Event<A>, screen: &mut Screen, painter: &Painter ) -> Window

calls update and checks returned scope to conform to requirements in debug builds

Auto Trait Implementations§

§

impl<F, M, A> RefUnwindSafe for TextBox<F, M, A>where A: RefUnwindSafe, F: RefUnwindSafe, M: RefUnwindSafe,

§

impl<F, M, A> Send for TextBox<F, M, A>where A: Send, F: Send, M: Send,

§

impl<F, M, A> Sync for TextBox<F, M, A>where A: Sync, F: Sync, M: Sync,

§

impl<F, M, A> Unpin for TextBox<F, M, A>where F: Unpin, M: Unpin,

§

impl<F, M, A> UnwindSafe for TextBox<F, M, A>where A: UnwindSafe, F: UnwindSafe, M: UnwindSafe,

Blanket Implementations§

source§

impl<T> AnchorPlaced for Twhere T: AnchorPlacementEnabled,

§

type Placed = PlacedWidget<T>

source§

fn left(self, offset: impl Into<Option<u16>>) -> <T as AnchorPlaced>::Placed

how far from the left?
source§

fn top(self, offset: impl Into<Option<u16>>) -> <T as AnchorPlaced>::Placed

how far from the top?
source§

fn right(self, offset: impl Into<Option<u16>>) -> <T as AnchorPlaced>::Placed

how far from the right?
source§

fn bottom(self, offset: impl Into<Option<u16>>) -> <T as AnchorPlaced>::Placed

how far from the botton?
source§

fn height(self, size: impl Into<Option<u16>>) -> <T as AnchorPlaced>::Placed

how high?
source§

fn width(self, size: impl Into<Option<u16>>) -> <T as AnchorPlaced>::Placed

how wide?
source§

fn fill(self) -> <T as AnchorPlaced>::Placed

reset to fill the whole area
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
source§

impl<'a, T, M, A> WidgetExt<M, A> for Twhere A: AppEvent, T: Widget<M, A>,

source§

fn bind_with( self, loader: impl Fn(&mut T, &M) + 'static, saver: impl Fn(&T, &mut M) + 'static ) -> WidgetBinder<T, M, A>

Decorate the given widget with a loader and saver. Read more
source§

fn replace_with( self, loader: impl Fn(T, &M) -> T + 'static ) -> WidgetBinder<T, M, A>where T: Default,

source§

fn load_with( self, loader: impl Fn(&mut T, &M) + 'static ) -> WidgetBinder<T, M, A>

A variation on bind_with, only a loader
source§

fn save_with( self, saver: impl Fn(&T, &mut M) + 'static ) -> WidgetBinder<T, M, A>

A variation on bind_with, only a saver
source§

fn bind_property<FW, FM, D>( self, widget_property: FW, model_property: FM ) -> WidgetPropertyBinder<T, M, D, A>where FW: Fn(&mut T) -> &mut D + 'static, FM: Fn(&mut M) -> &mut D + 'static, D: Default,

A variation on bind_with, bind specific model and widget properties