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: ColorImplementations§
Source§impl<'a> TextInput<'a>
impl<'a> TextInput<'a>
Sourcepub fn new(state: &'a mut TextInputState) -> Self
pub fn new(state: &'a mut TextInputState) -> Self
creates a new TextInput
Sourcepub fn state(self, value: &'a mut TextInputState) -> Self
pub fn state(self, value: &'a mut TextInputState) -> Self
sets Self::state
Sourcepub fn multiline(self, value: bool) -> Self
pub fn multiline(self, value: bool) -> Self
sets Self::multiline
Sourcepub fn keymap(self, value: fn(KeyboardEvent<'_>, bool) -> Option<Edit>) -> Self
pub fn keymap(self, value: fn(KeyboardEvent<'_>, bool) -> Option<Edit>) -> Self
sets Self::keymap
Sourcepub fn style(self, value: TextStyle<'a>) -> Self
pub fn style(self, value: TextStyle<'a>) -> Self
sets Self::style
Sourcepub fn padding(self, value: Sides<f32>) -> Self
pub fn padding(self, value: Sides<f32>) -> Self
sets Self::padding
Sourcepub fn placeholder(self, value: impl Into<StrSource<'a>>) -> Self
pub fn placeholder(self, value: impl Into<StrSource<'a>>) -> Self
sets Self::placeholder
Sourcepub fn placeholder_color(self, value: Color) -> Self
pub fn placeholder_color(self, value: Color) -> Self
Sourcepub fn selection_background(self, value: Color) -> Self
pub fn selection_background(self, value: Color) -> Self
Sourcepub fn cursor_background(self, value: Color) -> Self
pub fn cursor_background(self, value: Color) -> Self
Trait Implementations§
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>
impl<'a> Move for TextInput<'a>
impl<'a> RefUnwindSafe for TextInput<'a>
impl<'a> Unpin for TextInput<'a>
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> 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