pub struct TextField { /* private fields */ }Expand description
A Material presentation for a caller-owned Base text editing entity.
Keep the entity across renders. It owns selection, undo, composition, focus,
and text. Subscribe to super::TextFieldEvent on the entity to observe user
edits. Set disabled and read-only on the entity before rendering.
Implementations§
Source§impl TextField
impl TextField
Sourcepub fn new(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
state: &Entity<TextFieldState>,
) -> Self
pub fn new( id: impl Into<ElementId>, label: impl Into<SharedString>, state: &Entity<TextFieldState>, ) -> Self
Renders a single-line editor.
Sourcepub fn multiline(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
state: &Entity<TextAreaState>,
) -> Self
pub fn multiline( id: impl Into<ElementId>, label: impl Into<SharedString>, state: &Entity<TextAreaState>, ) -> Self
Renders a multi-line editor using the row policy configured in its state.
Sourcepub fn secure(
id: impl Into<ElementId>,
label: impl Into<SharedString>,
state: &Entity<TextFieldState>,
) -> Self
pub fn secure( id: impl Into<ElementId>, label: impl Into<SharedString>, state: &Entity<TextFieldState>, ) -> Self
Always masks the editor and suppresses its value from accessibility.
Use a dedicated entity initialized with TextFieldState::masked(true)
so the text is protected even before this field is first rendered.
pub fn variant(self, variant: TextFieldVariant) -> Self
Sourcepub fn font_scale(self, scale: f32) -> Self
pub fn font_scale(self, scale: f32) -> Self
Applies the caller’s user text scale to the editor, label, and supporting text.
Sourcepub fn text_style(self, style: TypeStyle) -> Self
pub fn text_style(self, style: TypeStyle) -> Self
Overrides the Material type metrics for input, hint, and affixes before applying font scale.
Sourcepub fn shape(self, shape: CornerShape) -> Self
pub fn shape(self, shape: CornerShape) -> Self
Overrides the container’s logical corner shape. Full uses the laid-out bounds.
Sourcepub fn content_padding(self, padding: Edges<Pixels>) -> Self
pub fn content_padding(self, padding: Edges<Pixels>) -> Self
Sets physical editor insets. An Inside label reserves additional height above the editor.
Sourcepub fn colors(self, colors: TextFieldColors) -> Self
pub fn colors(self, colors: TextFieldColors) -> Self
Applies per-state color overrides while preserving theme defaults for unset colors.
Sourcepub fn on_text_layout(
self,
listener: impl FnOnce(TextFieldLayout, &mut Window, &mut App) + 'static,
) -> Self
pub fn on_text_layout( self, listener: impl FnOnce(TextFieldLayout, &mut Window, &mut App) + 'static, ) -> Self
Called after paint when the editor’s reported layout changes. Subscribe to the Base entity for text changes that do not affect layout.
Sourcepub fn interaction_source(self, source: &Entity<InteractionSource>) -> Self
pub fn interaction_source(self, source: &Entity<InteractionSource>) -> Self
Observes hover, keyboard-visible focus, and disabled state through a shared source. Editing and selection stay with the Base entity.
pub fn supporting_text(self, text: impl Into<SharedString>) -> Self
Sourcepub fn label_content(self, element: impl IntoElement) -> Self
pub fn label_content(self, element: impl IntoElement) -> Self
Replaces the visible label. The constructor label remains the accessible name.
pub fn label_position(self, position: TextFieldLabelPosition) -> Self
Sourcepub fn label_always_minimized(self, minimized: bool) -> Self
pub fn label_always_minimized(self, minimized: bool) -> Self
Keeps an Inside or Cutout label minimized so affixes and hints can remain visible.
Sourcepub fn label_alignment(
self,
expanded: TextFieldLabelAlignment,
minimized: TextFieldLabelAlignment,
) -> Self
pub fn label_alignment( self, expanded: TextFieldLabelAlignment, minimized: TextFieldLabelAlignment, ) -> Self
Configures the alignment in each label state. Above uses minimized.
Sourcepub fn placeholder_content(
self,
hint: impl Into<SharedString>,
element: impl IntoElement,
) -> Self
pub fn placeholder_content( self, hint: impl Into<SharedString>, element: impl IntoElement, ) -> Self
Replaces the Base placeholder’s presentation. hint is the accessible placeholder.
Sourcepub fn supporting_content(
self,
description: impl Into<SharedString>,
element: impl IntoElement,
) -> Self
pub fn supporting_content( self, description: impl Into<SharedString>, element: impl IntoElement, ) -> Self
Supplies custom supporting content and the field’s plain-text accessible description.
Sourcepub fn error(self, message: impl Into<SharedString>) -> Self
pub fn error(self, message: impl Into<SharedString>) -> Self
Displays an error message in place of the supporting text.
Sourcepub fn invalid(self, invalid: bool) -> Self
pub fn invalid(self, invalid: bool) -> Self
Sets the invalid visual and accessibility state independently of the supporting content.
Sourcepub fn required(self, required: bool) -> Self
pub fn required(self, required: bool) -> Self
Displays a required mark and reports the required state to assistive technology.
Sourcepub fn character_count(self, limit: usize) -> Self
pub fn character_count(self, limit: usize) -> Self
Shows a Unicode scalar count and the supplied limit. Base still owns validation. The count is omitted for secure or masked fields.
Sourcepub fn leading(self, element: impl IntoElement) -> Self
pub fn leading(self, element: impl IntoElement) -> Self
Places an adornment in the 48 dp leading icon slot.
Sourcepub fn trailing(self, element: impl IntoElement) -> Self
pub fn trailing(self, element: impl IntoElement) -> Self
Places an addon at the logical end of the editing region.
Sourcepub fn prefix(self, element: impl IntoElement) -> Self
pub fn prefix(self, element: impl IntoElement) -> Self
Places an element before the value while the label is minimized.
Sourcepub fn suffix(self, element: impl IntoElement) -> Self
pub fn suffix(self, element: impl IntoElement) -> Self
Places an element after the value while the label is minimized.
Trait Implementations§
Source§impl IntoElement for TextField
impl IntoElement for TextField
Source§type Element = ViewElement<TextField>
type Element = ViewElement<TextField>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for TextField
impl RenderOnce for TextField
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for TextField
impl !Send for TextField
impl !Sync for TextField
impl !UnwindSafe for TextField
impl Forget for TextField
impl Freeze for TextField
impl Move for TextField
impl Unpin for TextField
impl UnsafeUnpin for TextField
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.