Skip to main content

TextInput

Struct TextInput 

Source
pub struct TextInput<'a> {
    pub state: &'a mut TextInputState,
    pub multiline: bool,
    pub keymap: fn(KeyboardEvent<'_>, bool) -> Option<Edit>,
    pub style: TextStyle<'a>,
    pub padding: Sides<f32>,
    pub placeholder: StrSource<'a>,
    pub placeholder_color: Color,
    pub selection_background: Color,
    pub cursor_background: Color,
}
Expand description

single or multiline text editing with configurable keyboard bindings

Self::keymap overrides default_keymap and receives Self::multiline. return None to let an event bubble. the edited text lives in TextInputState only the text, selection, and caret are painted so callers draw any frame behind it

Fields§

§state: &'a mut TextInputState§multiline: bool§keymap: fn(KeyboardEvent<'_>, bool) -> Option<Edit>§style: TextStyle<'a>§padding: Sides<f32>§placeholder: StrSource<'a>§placeholder_color: Color§selection_background: Color§cursor_background: Color

Implementations§

Source§

impl<'a> TextInput<'a>

Source

pub fn new(state: &'a mut TextInputState) -> Self

creates a new TextInput

Source

pub fn state(self, value: &'a mut TextInputState) -> Self

Source

pub fn multiline(self, value: bool) -> Self

Source

pub fn keymap(self, value: fn(KeyboardEvent<'_>, bool) -> Option<Edit>) -> Self

Source

pub fn style(self, value: TextStyle<'a>) -> Self

Source

pub fn padding(self, value: Sides<f32>) -> Self

Source

pub fn placeholder(self, value: impl Into<StrSource<'a>>) -> Self

Source

pub fn placeholder_color(self, value: Color) -> Self

Source

pub fn selection_background(self, value: Color) -> Self

Source

pub fn cursor_background(self, value: Color) -> Self

Trait Implementations§

Source§

impl<C> Widget<C> for TextInput<'_>

Source§

type Response = Response

Source§

fn build(self, ui: Ui<'_, C>) -> Self::Response

Auto Trait Implementations§

§

impl<'a> !Send for TextInput<'a>

§

impl<'a> !Sync for TextInput<'a>

§

impl<'a> !UnwindSafe for TextInput<'a>

§

impl<'a> Forget for TextInput<'a>

§

impl<'a> Freeze for TextInput<'a>
where &'a mut State<f32>: Freeze, &'a [([u8; 4], u32)]: Freeze, &'a [([u8; 4], f32)]: Freeze, &'a str: Freeze, *const u8 is !null: Freeze, *const Argument<'a> is !null: Freeze,

§

impl<'a> Move for TextInput<'a>

§

impl<'a> RefUnwindSafe for TextInput<'a>

§

impl<'a> Unpin for TextInput<'a>
where &'a mut State<f32>: Unpin, &'a [([u8; 4], u32)]: Unpin, &'a [([u8; 4], f32)]: Unpin, &'a str: Unpin, *const u8 is !null: Unpin, *const Argument<'a> is !null: Unpin,

§

impl<'a> UnsafeUnpin for TextInput<'a>
where &'a mut State<f32>: UnsafeUnpin, &'a [([u8; 4], u32)]: UnsafeUnpin, &'a [([u8; 4], f32)]: UnsafeUnpin, &'a str: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, *const Argument<'a> is !null: UnsafeUnpin,

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

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

fn try_from(value: U) -> Result<T, !>

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.