pub struct TextArea { /* private fields */ }Expand description
A multiline text field. Create with cx.new(|cx| TextArea::new(cx)).
Implementations§
Source§impl TextArea
impl TextArea
pub fn new(cx: &mut Context<'_, Self>) -> Self
pub fn value(self, value: &str) -> Self
pub fn placeholder(self, placeholder: impl Into<SharedString>) -> Self
Sourcepub fn set_placeholder(
&mut self,
placeholder: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_placeholder( &mut self, placeholder: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Replace the placeholder after construction, for a field that is built once and re-labelled later.
pub fn label(self, label: impl Into<SharedString>) -> Self
pub fn description(self, description: impl Into<SharedString>) -> Self
pub fn error(self, error: impl Into<SharedString>) -> Self
Sourcepub fn max_rows(self, rows: usize) -> Self
pub fn max_rows(self, rows: usize) -> Self
Stop growing past rows and scroll instead. Without this a field that
grows with its content has no ceiling, which is wrong for a composer
pinned to the bottom of a window.
Sourcepub fn submit_on_enter(self, submit: bool) -> Self
pub fn submit_on_enter(self, submit: bool) -> Self
Make Enter commit the value (emitting TextAreaSubmit) and
Shift+Enter insert the newline — the convention a chat composer uses.
pub fn size(self, size: Size) -> Self
pub fn disabled(self, disabled: bool) -> Self
Sourcepub fn focus_handle(&self) -> FocusHandle
pub fn focus_handle(&self) -> FocusHandle
The field’s focus handle, so a host can focus it on open.
pub fn text(&self) -> String
Sourcepub fn is_blank(&self) -> bool
pub fn is_blank(&self) -> bool
Whether the field holds nothing but whitespace. Cheaper than
text().trim().is_empty(), which builds and throws away a copy of the
whole value — and callers ask this every frame to enable a send button.
pub fn set_text(&mut self, value: &str, cx: &mut Context<'_, Self>)
Sourcepub fn bind(entity: &Entity<TextArea>, signal: &Signal<String>, cx: &mut App)
pub fn bind(entity: &Entity<TextArea>, signal: &Signal<String>, cx: &mut App)
Two-way bind this field’s text to a Signal<String>. The signal is
the source of truth: the field adopts its value now, edits write back
through Signal::set_if_changed, and signal writes replace the text.
Equality guards on both directions prevent update loops.
Trait Implementations§
impl EventEmitter<TextAreaEvent> for TextArea
impl EventEmitter<TextAreaSubmit> for TextArea
Auto Trait Implementations§
impl !RefUnwindSafe for TextArea
impl !Send for TextArea
impl !Sync for TextArea
impl !UnwindSafe for TextArea
impl Freeze for TextArea
impl Unpin for TextArea
impl UnsafeUnpin for TextArea
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.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