Skip to main content

TextBox

Struct TextBox 

Source
pub struct TextBox { /* private fields */ }

Implementations§

Source§

impl TextBox

Source

pub fn new() -> Self

Source

pub fn value(self, value: impl Into<String>) -> Self

Source

pub fn text(&self) -> &str

Source

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

Source

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

Source

pub fn read_only(self, value: bool) -> Self

Source

pub fn on_change(self, f: impl FnMut(&str, &mut EventCtx) + 'static) -> Self

Source

pub fn on_submit(self, f: impl FnMut(&str, &mut EventCtx) + 'static) -> Self

Source§

impl TextBox

Source

pub fn on_click(self, f: impl FnMut(&mut EventCtx) + 'static) -> Self

Source

pub fn on_hover(self, f: impl FnMut(bool, &mut EventCtx) + 'static) -> Self

Source

pub fn on_mouse_enter(self, f: impl FnMut(&mut EventCtx) + 'static) -> Self

Source

pub fn on_mouse_leave(self, f: impl FnMut(&mut EventCtx) + 'static) -> Self

Source

pub fn on_mouse_input( self, f: impl FnMut(ElementState, MouseButton, &mut EventCtx) + 'static, ) -> Self

Source

pub fn on_key( self, f: impl FnMut(&KeyboardEvent, &mut EventCtx) + 'static, ) -> Self

Source

pub fn window_drag_region(self, value: bool) -> Self

Source§

impl TextBox

Source

pub fn key(self, key: impl Into<SmolStr>) -> Self

Stable identity among siblings, kept across rebuilds even when this widget moves position (reorder, insert, remove). Use for list items instead of relying on array index.

Source

pub fn font(self, font: impl Into<SmolStr>) -> Self

Source

pub fn hover_background<M>( self, background: impl IntoThemed<Background, M>, ) -> Self

Source

pub fn pressed_background<M>( self, background: impl IntoThemed<Background, M>, ) -> Self

Source

pub fn disabled_background<M>( self, background: impl IntoThemed<Background, M>, ) -> Self

Source

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

Source§

impl TextBox

Source

pub fn hover_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self

Source

pub fn pressed_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self

Source

pub fn focus_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self

Source

pub fn disabled_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self

Source

pub fn focused_hover_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self

Trait Implementations§

Source§

impl Default for TextBox

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl StyleBuilder for TextBox

Source§

fn style_mut(&mut self) -> &mut Style

Source§

fn mark_dirty(&mut self)

Source§

fn width<M>(self, width: impl IntoThemed<Length, M>) -> Self

Source§

fn height<M>(self, height: impl IntoThemed<Length, M>) -> Self

Source§

fn size<W, H, MW, MH>(self, width: W, height: H) -> Self
where W: IntoThemed<Length, MW>, H: IntoThemed<Length, MH>,

Source§

fn padding<M>(self, padding: impl IntoThemed<Edges, M>) -> Self

Source§

fn color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn selection_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn selection_background<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn caret_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn selection_border_width<M>(self, width: impl IntoThemed<Length, M>) -> Self

Source§

fn selection_border_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn selection_border_radius<M>(self, radius: impl IntoThemed<Length, M>) -> Self

Source§

fn cursor(self, cursor: Cursor) -> Self

Source§

fn background<M>(self, background: impl IntoThemed<Background, M>) -> Self

Source§

fn font_size<M>(self, size: impl IntoThemed<Length, M>) -> Self

Source§

fn font_weight(self, weight: FontWeight) -> Self

Source§

fn font_style(self, style: FontStyle) -> Self

Source§

fn letter_spacing(self, spacing: impl Into<LetterSpacing>) -> Self

Source§

fn text_align(self, align: TextAlign) -> Self

Source§

fn text_decoration(self, decoration: TextDecoration) -> Self

Source§

fn line_height(self, height: impl Into<LineHeight>) -> Self

Source§

fn margin<M>(self, margin: impl IntoThemed<Edges, M>) -> Self

Source§

fn border<M>(self, border: impl IntoThemed<Border, M>) -> Self

Source§

fn outline<M>(self, outline: impl IntoThemed<StyleValue<Outline>, M>) -> Self

Source§

fn box_shadow(self, shadows: impl Into<Vec<BoxShadow>>) -> Self

Source§

fn box_shadow_none(self) -> Self

Source§

fn min_width<M>(self, width: impl IntoThemed<Length, M>) -> Self

Source§

fn min_height<M>(self, height: impl IntoThemed<Length, M>) -> Self

Source§

fn min_size<W, H, MW, MH>(self, width: W, height: H) -> Self
where W: IntoThemed<Length, MW>, H: IntoThemed<Length, MH>,

Source§

fn max_width<M>(self, width: impl IntoThemed<Length, M>) -> Self

Source§

fn max_height<M>(self, height: impl IntoThemed<Length, M>) -> Self

Source§

fn max_size<W, H, MW, MH>(self, width: W, height: H) -> Self
where W: IntoThemed<Length, MW>, H: IntoThemed<Length, MH>,

Source§

fn display(self, display: Display) -> Self

Source§

fn position(self, position: Position) -> Self

Source§

fn top<M>(self, value: impl IntoThemed<Length, M>) -> Self

Source§

fn right<M>(self, value: impl IntoThemed<Length, M>) -> Self

Source§

fn bottom<M>(self, value: impl IntoThemed<Length, M>) -> Self

Source§

fn left<M>(self, value: impl IntoThemed<Length, M>) -> Self

Source§

fn z_index(self, z_index: i32) -> Self

Paint order relative to siblings; higher values paint later, on top.
Source§

fn overflow_x(self, overflow: Overflow) -> Self

Source§

fn overflow_y(self, overflow: Overflow) -> Self

Source§

fn overflow(self, x: Overflow, y: Overflow) -> Self

Source§

fn overscroll(self, overscroll: Overscroll) -> Self

Source§

fn flex_direction(self, direction: FlexDirection) -> Self

Source§

fn flex_wrap(self, wrap: FlexWrap) -> Self

Source§

fn flex_grow(self, grow: f32) -> Self

Source§

fn flex_shrink(self, shrink: f32) -> Self

Source§

fn flex_basis<M>(self, basis: impl IntoThemed<Length, M>) -> Self

Source§

fn align_items(self, align: AlignItems) -> Self

Source§

fn align_self(self, align: AlignItems) -> Self

Source§

fn justify_content(self, justify: JustifyContent) -> Self

Source§

fn align_content(self, align: JustifyContent) -> Self

Source§

fn gap<W, H, MW, MH>(self, horizontal: W, vertical: H) -> Self
where W: IntoThemed<Length, MW>, H: IntoThemed<Length, MH>,

Source§

fn grid_template_columns(self, columns: impl Into<Vec<GridTrack>>) -> Self

Source§

fn grid_template_rows(self, rows: impl Into<Vec<GridTrack>>) -> Self

Source§

fn grid_column(self, column: GridPlacement) -> Self

Source§

fn grid_row(self, row: GridPlacement) -> Self

Source§

fn scrollbar_gutter(self, gutter: ScrollbarGutter) -> Self

Source§

fn scrollbar_thickness(self, thickness: f32) -> Self

Source§

fn scrollbar_min_thumb_length(self, length: f32) -> Self

Source§

fn scrollbar_thumb_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn scrollbar_thumb_radius<M>(self, radius: impl IntoThemed<f32, M>) -> Self

Source§

fn scrollbar_track_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn scrollbar_button_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn scrollbar_arrow_color<M>(self, color: impl IntoThemed<Color, M>) -> Self

Source§

fn scrollbar_thumb_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_track_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_hover_thickness(self, thickness: f32) -> Self

Source§

fn scrollbar_hover_min_thumb_length(self, length: f32) -> Self

Source§

fn scrollbar_hover_thumb_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_hover_thumb_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_hover_track_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_hover_track_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_hover_button_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_hover_arrow_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_pressed_thickness(self, thickness: f32) -> Self

Source§

fn scrollbar_pressed_min_thumb_length(self, length: f32) -> Self

Source§

fn scrollbar_pressed_thumb_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_pressed_thumb_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_pressed_track_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_pressed_track_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_pressed_button_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scrollbar_pressed_arrow_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self

Source§

fn scale(self, scale: f32) -> Self

Source§

fn content_scale(self, scale: f32) -> Self

Source§

fn transition(self, transition: Transition) -> Self

Source§

fn transition_all(self, transition: Transition) -> Self

Source§

fn transition_colors(self, transition: Transition) -> Self

Source§

fn transition_opacity(self, transition: Transition) -> Self

Source§

fn transition_shadow(self, transition: Transition) -> Self

Source§

fn transition_transform(self, transition: Transition) -> Self

Source§

fn transition_none(self) -> Self

Source§

impl Widget for TextBox

Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

fn get_key(&self) -> Option<&SmolStr>

Source§

fn is_dirty(&self) -> bool

Source§

fn set_dirty(&mut self, dirty: bool)

Source§

fn style(&self) -> &Style

Source§

fn style_mut(&mut self) -> &mut Style

Source§

fn computed_style(&self) -> &Style

Source§

fn interaction(&self) -> Option<&Interaction>

Source§

fn interaction_mut(&mut self) -> Option<&mut Interaction>

Source§

fn layout(&mut self, rect: LayoutBox)

Source§

fn layout_box(&self) -> &LayoutBox

Source§

fn debug_name(&self) -> &'static str

Source§

fn measure( &self, ctx: &mut MeasureContext<'_>, constraints: Constraints, ) -> MeasureResult

Source§

fn paint(&self, ctx: &mut PaintContext<'_>)

Source§

fn event(&mut self, event: &InputEvent, ctx: &mut EventCtx) -> EventStatus

Source§

fn content_eq(&self, other: &dyn Widget) -> bool

Source§

fn cascade_style(&mut self, parent: &Style, anim: &mut AnimationManager)

Source§

fn after_interaction_transfer(&mut self)

Source§

fn transfer_interaction_state(&mut self, old: &dyn Widget)

Source§

fn transfer_measured_state(&mut self, old: &dyn Widget)

Source§

fn cancel_text_selection(&mut self)

Source§

fn anim_id(&self) -> WidgetId

Stable per-instance animation key namespace. Assign once in the constructor via WidgetId::new_unique() and preserve it across reconciliation so in-flight transitions aren’t reset.
Source§

fn native_text_input(&self) -> Option<NativeTextInputSnapshot>

Some(...) marks this widget as backed by a real DOM <input> on web targets. None (the default) means it has no native counterpart.
Source§

fn set_native_text_value(&mut self, value: &str, ctx: &mut EventCtx)

Applies a value typed into the native DOM <input> back onto this widget’s own state.
Source§

fn on_mount(&mut self)

Called once, right after this widget is inserted into the tree.
Source§

fn on_unmount(&mut self)

Called once, right before this widget is permanently removed from the tree.
Source§

fn children(&self) -> &[Box<dyn Widget>]

Source§

fn children_mut(&mut self) -> Option<&mut Vec<Box<dyn Widget>>>

Source§

fn scroll_offset(&self) -> (f32, f32)

Additional scroll translation applied to this widget’s children during layout, in logical pixels.
Source§

fn set_content_size(&mut self, _size: (f32, f32))

Reports this widget’s total content size after layout, which may exceed layout_box() when children overflow it.
Source§

fn clip_children(&self) -> Option<(f32, f32, f32, f32)>

The rectangle this widget clips its children’s painted output to, in absolute screen coordinates. None means no clipping.
Source§

fn on_layout_pass(&self, _ctx: &mut MeasureContext<'_>)

Runs once per full layout pass for every widget, leaf or not, purely so a widget can cache intrinsic measurements it needs later for painting (e.g. a popup’s natural width) without affecting its own flex/grid size, which measure alone controls.
Source§

fn paint_overlay(&self, _ctx: &mut PaintContext<'_>)

Painted after every descendant, on top of them, and never cached - used for overlays like a scrollbar thumb that depend on live state.
Source§

fn paint_box(&self, ctx: &mut PaintContext<'_>)

Source§

fn paint_edge_borders( &self, ctx: &mut PaintContext<'_>, layout: LayoutBox, b: &Border, sf: f32, )

Source§

fn paint_shadow_layer( &self, ctx: &mut PaintContext<'_>, layout: LayoutBox, radius: f32, shadow: &BoxShadow, sf: f32, )

Source§

fn paint_outline(&self, ctx: &mut PaintContext<'_>)

Source§

fn paint_focus(&self, ctx: &mut PaintContext<'_>)

Source§

fn paint_top(&self, _ctx: &mut PaintContext<'_>)

Painted after every other widget’s own content and after all deferred text has been flushed - use this instead of paint_overlay for a popup that must render above everything else, including other widgets’ text (which is otherwise batched and flushed in its own pass after every widget’s rects).
Source§

fn hit_test(&self, point: (f32, f32)) -> bool

Source§

fn blocks_children_hit_test(&self, _point: (f32, f32)) -> bool

When true at point, hit-testing stops at this widget instead of descending into its children.
Source§

fn wants_animation_frame(&self) -> bool

Whether this widget needs a continuous per-frame animation callback (InputEvent::AnimationTick) right now, independent of focus.
Source§

fn selectable_text(&self) -> Option<&str>

HTML-style selectable text content for mouse selection / Ctrl+C. None opts the widget out entirely (e.g. Button, TextBox).
Source§

fn text_selection(&self) -> Option<(usize, usize)>

Source§

fn set_text_selection(&mut self, _range: Option<(usize, usize)>)

Source§

fn text_index_at(&self, _point: (f32, f32)) -> usize

Nearest character index to an absolute screen point, used by cross-widget drag selection to know where a widget’s own selection should start or end.
Source§

fn select_all_text(&mut self)

Source§

impl WidgetContent for TextBox

Source§

fn with_content(self, content: impl Into<SmolStr>) -> Self

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.