pub struct TextareaState {
pub scroll_handle: ScrollHandle,
pub content: SharedString,
pub placeholder: SharedString,
pub disabled: bool,
pub initialized: bool,
pub validation_rules: ValidationRules,
pub validation_error: Option<ValidationError>,
pub success_message: Option<SharedString>,
pub validate_on_blur: bool,
pub validate_on_change: bool,
/* private fields */
}Expand description
Multi-line text input state with cursor management
Fields§
§scroll_handle: ScrollHandle§content: SharedString§placeholder: SharedString§disabled: bool§initialized: bool§validation_rules: ValidationRules§validation_error: Option<ValidationError>§success_message: Option<SharedString>§validate_on_blur: bool§validate_on_change: boolImplementations§
Source§impl TextareaState
impl TextareaState
pub fn new(cx: &mut Context<'_, Self>) -> Self
Sourcepub fn placeholder(self, placeholder: impl Into<SharedString>) -> Self
pub fn placeholder(self, placeholder: impl Into<SharedString>) -> Self
Set the placeholder text.
Sourcepub fn value(self, value: impl Into<SharedString>) -> Self
pub fn value(self, value: impl Into<SharedString>) -> Self
Set the initial value.
Equivalent to assigning content directly, but leaves the caret at
the end of the text. This is raw initialization: it bypasses
validation rules and max_length truncation. To replace the value
later with truncation, validation, and a Change event, use
TextareaState::set_value.
pub fn content(&self) -> &str
pub fn visual_line_count_for_layout(&self) -> usize
pub fn set_value( &mut self, value: impl Into<SharedString>, _window: &mut Window, cx: &mut Context<'_, Self>, )
Sourcepub fn is_composing(&self) -> bool
pub fn is_composing(&self) -> bool
Whether an IME composition is currently in progress.
While composing, the in-flight text is displayed but not committed:
validation and max_length truncation only apply on commit.
Sourcepub fn composition_char_count(&self) -> usize
pub fn composition_char_count(&self) -> usize
Number of characters in the in-flight IME composition (0 when not
composing). content() includes these characters, so the committed
length is content().chars().count() - composition_char_count().
Sourcepub fn validation_rules(self, rules: ValidationRules) -> Self
pub fn validation_rules(self, rules: ValidationRules) -> Self
Set validation rules
Sourcepub fn min_length(self, min: usize) -> Self
pub fn min_length(self, min: usize) -> Self
Set minimum length
Sourcepub fn max_length(self, max: usize) -> Self
pub fn max_length(self, max: usize) -> Self
Set maximum length
Sourcepub fn validate(
&mut self,
cx: &mut Context<'_, Self>,
) -> Result<(), ValidationError>
pub fn validate( &mut self, cx: &mut Context<'_, Self>, ) -> Result<(), ValidationError>
Validate the current value against the configured rules.
pub fn backspace( &mut self, _: &Backspace, window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn delete( &mut self, _: &Delete, window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn left(&mut self, _: &Left, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn right(&mut self, _: &Right, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn up(&mut self, _: &Up, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn down(&mut self, _: &Down, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn select_left( &mut self, _: &SelectLeft, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn select_right( &mut self, _: &SelectRight, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn select_up( &mut self, _: &SelectUp, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn select_down( &mut self, _: &SelectDown, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn select_all( &mut self, _: &SelectAll, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn home(&mut self, _: &Home, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn end(&mut self, _: &End, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn word_left( &mut self, _: &WordLeft, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn word_right( &mut self, _: &WordRight, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn select_word_left( &mut self, _: &SelectWordLeft, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn select_word_right( &mut self, _: &SelectWordRight, _: &mut Window, cx: &mut Context<'_, Self>, )
pub fn enter( &mut self, _: &Enter, window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn shift_enter( &mut self, _: &ShiftEnter, _window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn tab(&mut self, _: &Tab, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn shift_tab( &mut self, _: &ShiftTab, _window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn copy(&mut self, _: &Copy, _: &mut Window, cx: &mut Context<'_, Self>)
pub fn cut(&mut self, _: &Cut, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn paste( &mut self, _: &Paste, window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn escape( &mut self, _: &Escape, _window: &mut Window, cx: &mut Context<'_, Self>, )
Trait Implementations§
Source§impl EntityInputHandler for TextareaState
impl EntityInputHandler for TextareaState
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 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<TextareaEvent> for TextareaState
Source§impl Focusable for TextareaState
impl Focusable for TextareaState
Source§fn focus_handle(&self, _: &App) -> FocusHandle
fn focus_handle(&self, _: &App) -> FocusHandle
Source§impl Render for TextareaState
impl Render for TextareaState
Auto Trait Implementations§
impl !RefUnwindSafe for TextareaState
impl !Send for TextareaState
impl !Sync for TextareaState
impl !UnwindSafe for TextareaState
impl Freeze for TextareaState
impl Unpin for TextareaState
impl UnsafeUnpin for TextareaState
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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