pub struct TextInput { /* private fields */ }Expand description
One line of editable text.
The field owns the caret, the selection, and any composition in flight; the committed text belongs to the caller, which is why a host that refuses a change simply does not apply it and the field keeps showing what is true. A secret field publishes its shape and never its content.
Implementations§
Source§impl TextInput
impl TextInput
pub fn new( ident: impl Into<Ident>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
pub fn placeholder(self, placeholder: impl Into<SharedString>) -> Self
Sourcepub fn name(self, name: impl Into<SharedString>) -> Self
pub fn name(self, name: impl Into<SharedString>) -> Self
Names the field for a reader without drawing anything. Use it when a surrounding control carries the visible label.
Sourcepub fn set_name(
&mut self,
name: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_name( &mut self, name: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Names the field after it has been built.
Sourcepub fn text(self, text: impl Into<SharedString>) -> Self
pub fn text(self, text: impl Into<SharedString>) -> Self
Seeds the initial text, with the caret at the end.
pub fn invalid(self, invalid: bool) -> Self
pub fn required(self, required: bool) -> Self
Sourcepub fn read_only(self, read_only: bool) -> Self
pub fn read_only(self, read_only: bool) -> Self
Keeps the value focusable and selectable while refusing editing, IME, and accessibility value changes.
Sourcepub fn secret(self, secret: bool) -> Self
pub fn secret(self, secret: bool) -> Self
Renders as dots and keeps the text out of every snapshot and export.
Sourcepub fn bare(self, bare: bool) -> Self
pub fn bare(self, bare: bool) -> Self
Drops the input’s own border and background.
For a control that composes the input with something else — a step
button, a token list — and draws one crate::controls::field::field_shell
around the lot, so a composed field is not two nested frames.
Sourcepub fn max_length(self, max_length: usize) -> Self
pub fn max_length(self, max_length: usize) -> Self
Refuses input past a length in bytes of UTF-8.
pub fn value(&self) -> &SharedString
pub fn is_empty(&self) -> bool
Sourcepub fn set_value(
&mut self,
value: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_value( &mut self, value: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Replaces the text from the host side, for example when a form resets.
pub fn set_placeholder( &mut self, placeholder: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Sourcepub fn set_text_quietly(
&mut self,
value: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_text_quietly( &mut self, value: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Replaces the text without reporting a change.
For a composing control that is putting its owner’s value on screen: nobody asked for that text, so reporting it as an edit would send the host a change it made itself.
pub fn set_disabled(&mut self, disabled: bool, cx: &mut Context<'_, Self>)
pub fn set_read_only(&mut self, read_only: bool, cx: &mut Context<'_, Self>)
pub fn set_invalid(&mut self, invalid: bool, cx: &mut Context<'_, Self>)
pub fn is_disabled(&self) -> bool
pub fn is_secret(&self) -> bool
pub fn selected_range(&self) -> Range<usize> ⓘ
pub fn cursor_offset(&self) -> usize
Trait Implementations§
Source§impl EntityInputHandler for TextInput
impl EntityInputHandler for TextInput
Source§fn text_for_range(
&mut self,
range_utf16: Range<usize>,
actual_range: &mut Option<Range<usize>>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<String>
fn text_for_range( &mut self, range_utf16: Range<usize>, actual_range: &mut Option<Range<usize>>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<String>
InputHandler::text_for_range for detailsSource§fn selected_text_range(
&mut self,
_ignore_disabled_input: bool,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<UTF16Selection>
fn selected_text_range( &mut self, _ignore_disabled_input: bool, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>
InputHandler::selected_text_range for detailsSource§fn marked_text_range(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<Range<usize>>
fn marked_text_range( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>
InputHandler::marked_text_range for detailsSource§fn unmark_text(&mut self, _window: &mut Window, _cx: &mut Context<'_, Self>)
fn unmark_text(&mut self, _window: &mut Window, _cx: &mut Context<'_, Self>)
InputHandler::unmark_text for detailsSource§fn replace_text_in_range(
&mut self,
range_utf16: Option<Range<usize>>,
new_text: &str,
_window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_text_in_range( &mut self, range_utf16: Option<Range<usize>>, new_text: &str, _window: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_text_in_range for detailsSource§fn replace_and_mark_text_in_range(
&mut self,
range_utf16: Option<Range<usize>>,
new_text: &str,
new_selected_range_utf16: Option<Range<usize>>,
_window: &mut Window,
cx: &mut Context<'_, Self>,
)
fn replace_and_mark_text_in_range( &mut self, range_utf16: Option<Range<usize>>, new_text: &str, new_selected_range_utf16: Option<Range<usize>>, _window: &mut Window, cx: &mut Context<'_, Self>, )
InputHandler::replace_and_mark_text_in_range for detailsSource§fn bounds_for_range(
&mut self,
range_utf16: Range<usize>,
bounds: Bounds<Pixels>,
_window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<Bounds<Pixels>>
fn bounds_for_range( &mut self, range_utf16: Range<usize>, bounds: Bounds<Pixels>, _window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>
InputHandler::bounds_for_range for detailsSource§fn character_index_for_point(
&mut self,
point: Point<Pixels>,
_window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Option<usize>
fn character_index_for_point( &mut self, point: Point<Pixels>, _window: &mut Window, cx: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::character_index_for_point for detailsSource§fn set_selected_text_range(
&mut self,
_range_utf16: Range<usize>,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
)
fn set_selected_text_range( &mut self, _range_utf16: Range<usize>, _window: &mut Window, _cx: &mut Context<'_, Self>, )
InputHandler::set_selected_text_range for detailsSource§fn text_length_utf16(
&mut self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> Option<usize>
fn text_length_utf16( &mut self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>
InputHandler::text_length_utf16 for detailsSource§fn accepts_text_input(
&self,
_window: &mut Window,
_cx: &mut Context<'_, Self>,
) -> bool
fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool
InputHandler::accepts_text_input for detailsimpl EventEmitter<TextInputEvent> for TextInput
Source§impl Focusable for TextInput
impl Focusable for TextInput
Source§fn focus_handle(&self, _cx: &App) -> FocusHandle
fn focus_handle(&self, _cx: &App) -> FocusHandle
Auto Trait Implementations§
impl !RefUnwindSafe for TextInput
impl !Send for TextInput
impl !Sync for TextInput
impl !UnwindSafe for TextInput
impl Freeze for TextInput
impl Unpin for TextInput
impl UnsafeUnpin for TextInput
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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