pub struct TextField { /* private fields */ }Expand description
A single-line text input bound to a String.
Supports typing, deleting, moving by character, word and line, selecting with Shift, the mouse (drag, double-click) or Cmd/Ctrl+A, copy, cut and paste, and Enter (submit). Passwords can be pasted but not copied.
use ravenrs_reactive::State;
use ravenrs_widgets::{IconName, TextField, Ui};
let query = State::new(String::new());
let field = TextField::new(query.binding()).placeholder("Search").icon(IconName::Search).clearable();
let mut ui = Ui::new(field, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl TextField
impl TextField
Sourcepub fn placeholder(self, text: impl Into<String>) -> TextField
pub fn placeholder(self, text: impl Into<String>) -> TextField
Muted text shown while the value is empty.
Sourcepub fn width(self, width: f32) -> TextField
pub fn width(self, width: f32) -> TextField
Fixed width in logical pixels; by default the field stretches.
Sourcepub fn compact(self) -> TextField
pub fn compact(self) -> TextField
A shorter field with smaller text, for toolbars, filter rows and cells: the same
as Self::size with ButtonSize::Small.
Sourcepub fn size(self, size: ButtonSize) -> TextField
pub fn size(self, size: ButtonSize) -> TextField
Sets the height and text size to line up with a Button of the
same size (Medium by default). The smaller ones have no minimum width.
Sourcepub fn prefix(self, view: impl View + 'static) -> TextField
pub fn prefix(self, view: impl View + 'static) -> TextField
Any view inside the field, before the text, such as a currency or a unit.
Sourcepub fn suffix(self, view: impl View + 'static) -> TextField
pub fn suffix(self, view: impl View + 'static) -> TextField
Any view inside the field, after the text, such as a unit or a button.
Sourcepub fn clearable(self) -> TextField
pub fn clearable(self) -> TextField
A button inside the field that empties it, shown while there is text to clear. The keyboard comes back to the field afterwards.
Sourcepub fn flat(self) -> TextField
pub fn flat(self) -> TextField
No box of its own until it is pointed at or focused, filling what it is in, for fields that line up with what is around them, as under the columns of a grid.
Sourcepub fn end_aligned(self) -> TextField
pub fn end_aligned(self) -> TextField
Puts the text at the end of the field, as under a column of numbers.
Sourcepub fn select_on_open(self) -> TextField
pub fn select_on_open(self) -> TextField
Starts with all of its text selected, so that typing replaces it.
Sourcepub fn on_cancel(self, handler: impl Fn() + 'static) -> TextField
pub fn on_cancel(self, handler: impl Fn() + 'static) -> TextField
Called when Escape is pressed while the field is focused.
Sourcepub fn intercept_keys(
self,
handler: Rc<dyn Fn(&Key, Modifiers) -> bool>,
) -> TextField
pub fn intercept_keys( self, handler: Rc<dyn Fn(&Key, Modifiers) -> bool>, ) -> TextField
Sees keys before the field edits; return true to consume them (lists navigated from a search field use it for arrows and Enter).
Sourcepub fn on_submit(self, handler: impl Fn(String) + 'static) -> TextField
pub fn on_submit(self, handler: impl Fn(String) + 'static) -> TextField
Called with the current text when Enter is pressed.
Sourcepub fn on_leave(self, handler: impl Fn() + 'static) -> TextField
pub fn on_leave(self, handler: impl Fn() + 'static) -> TextField
Called when the keyboard goes elsewhere after being here.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for TextField
impl !Send for TextField
impl !Sync for TextField
impl !UnwindSafe for TextField
impl Freeze for TextField
impl Unpin for TextField
impl UnsafeUnpin for TextField
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.