Skip to main content

TextareaState

Struct TextareaState 

Source
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: bool

Implementations§

Source§

impl TextareaState

Source

pub fn new(cx: &mut Context<'_, Self>) -> Self

Source

pub fn placeholder(self, placeholder: impl Into<SharedString>) -> Self

Set the placeholder text.

Source

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.

Source

pub fn disabled(self, disabled: bool) -> Self

Set whether user interaction is disabled.

Source

pub fn content(&self) -> &str

Source

pub fn visual_line_count_for_layout(&self) -> usize

Source

pub fn set_value( &mut self, value: impl Into<SharedString>, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source

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.

Source

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().

Source

pub fn validation_rules(self, rules: ValidationRules) -> Self

Set validation rules

Source

pub fn min_length(self, min: usize) -> Self

Set minimum length

Source

pub fn max_length(self, max: usize) -> Self

Set maximum length

Source

pub fn required(self, required: bool) -> Self

Mark field as required

Source

pub fn validate( &mut self, cx: &mut Context<'_, Self>, ) -> Result<(), ValidationError>

Validate the current value against the configured rules.

Source

pub fn backspace( &mut self, _: &Backspace, window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn delete( &mut self, _: &Delete, window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn left(&mut self, _: &Left, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn right(&mut self, _: &Right, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn up(&mut self, _: &Up, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn down(&mut self, _: &Down, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn select_left( &mut self, _: &SelectLeft, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_right( &mut self, _: &SelectRight, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_up( &mut self, _: &SelectUp, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_down( &mut self, _: &SelectDown, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_all( &mut self, _: &SelectAll, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn home(&mut self, _: &Home, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn end(&mut self, _: &End, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn word_left( &mut self, _: &WordLeft, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn word_right( &mut self, _: &WordRight, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_word_left( &mut self, _: &SelectWordLeft, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn select_word_right( &mut self, _: &SelectWordRight, _: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn enter( &mut self, _: &Enter, window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn shift_enter( &mut self, _: &ShiftEnter, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn tab(&mut self, _: &Tab, window: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn shift_tab( &mut self, _: &ShiftTab, _window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn copy(&mut self, _: &Copy, _: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn cut(&mut self, _: &Cut, window: &mut Window, cx: &mut Context<'_, Self>)

Source

pub fn paste( &mut self, _: &Paste, window: &mut Window, cx: &mut Context<'_, Self>, )

Source

pub fn escape( &mut self, _: &Escape, _window: &mut Window, cx: &mut Context<'_, Self>, )

Trait Implementations§

Source§

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>

Source§

fn selected_text_range( &mut self, _ignore_disabled_input: bool, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<UTF16Selection>

Source§

fn marked_text_range( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Range<usize>>

Source§

fn unmark_text(&mut self, _window: &mut Window, cx: &mut Context<'_, Self>)

Source§

fn replace_text_in_range( &mut self, range_utf16: Option<Range<usize>>, new_text: &str, window: &mut Window, cx: &mut Context<'_, Self>, )

Source§

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>, )

Source§

fn bounds_for_range( &mut self, range_utf16: Range<usize>, bounds: Bounds<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<Bounds<Pixels>>

Source§

fn character_index_for_point( &mut self, point: Point<Pixels>, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> Option<usize>

Source§

fn accepts_text_input( &self, _window: &mut Window, _cx: &mut Context<'_, Self>, ) -> bool

Source§

impl EventEmitter<TextareaEvent> for TextareaState

Source§

impl Focusable for TextareaState

Source§

fn focus_handle(&self, _: &App) -> FocusHandle

Returns the focus handle associated with this view.
Source§

impl Render for TextareaState

Source§

fn render( &mut self, _window: &mut Window, cx: &mut Context<'_, Self>, ) -> impl IntoElement

Render this view into an element tree.

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more