pub struct TextBox { /* private fields */ }Implementations§
Source§impl TextBox
impl TextBox
pub fn new() -> Self
pub fn value(self, value: impl Into<String>) -> Self
pub fn text(&self) -> &str
pub fn placeholder(self, placeholder: impl Into<SmolStr>) -> Self
pub fn max_length(self, max_length: usize) -> Self
pub fn read_only(self, value: bool) -> Self
pub fn on_change(self, f: impl FnMut(&str, &mut EventCtx) + 'static) -> Self
pub fn on_submit(self, f: impl FnMut(&str, &mut EventCtx) + 'static) -> Self
Source§impl TextBox
impl TextBox
pub fn on_click(self, f: impl FnMut(&mut EventCtx) + 'static) -> Self
pub fn on_hover(self, f: impl FnMut(bool, &mut EventCtx) + 'static) -> Self
pub fn on_mouse_enter(self, f: impl FnMut(&mut EventCtx) + 'static) -> Self
pub fn on_mouse_leave(self, f: impl FnMut(&mut EventCtx) + 'static) -> Self
pub fn on_mouse_input( self, f: impl FnMut(ElementState, MouseButton, &mut EventCtx) + 'static, ) -> Self
pub fn on_key( self, f: impl FnMut(&KeyboardEvent, &mut EventCtx) + 'static, ) -> Self
pub fn window_drag_region(self, value: bool) -> Self
Source§impl TextBox
impl TextBox
Sourcepub fn key(self, key: impl Into<SmolStr>) -> Self
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.
pub fn font(self, font: impl Into<SmolStr>) -> Self
pub fn hover_background<M>( self, background: impl IntoThemed<Background, M>, ) -> Self
pub fn pressed_background<M>( self, background: impl IntoThemed<Background, M>, ) -> Self
pub fn disabled_background<M>( self, background: impl IntoThemed<Background, M>, ) -> Self
pub fn enabled(self, enabled: bool) -> Self
Source§impl TextBox
impl TextBox
pub fn hover_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self
pub fn pressed_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self
pub fn focus_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self
pub fn disabled_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self
pub fn focused_hover_style( self, build: impl FnOnce(StylePatch, &Theme) -> StylePatch, ) -> Self
Trait Implementations§
Source§impl StyleBuilder for TextBox
impl StyleBuilder for TextBox
fn style_mut(&mut self) -> &mut Style
fn mark_dirty(&mut self)
fn width<M>(self, width: impl IntoThemed<Length, M>) -> Self
fn height<M>(self, height: impl IntoThemed<Length, M>) -> Self
fn size<W, H, MW, MH>(self, width: W, height: H) -> Self
fn padding<M>(self, padding: impl IntoThemed<Edges, M>) -> Self
fn color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn selection_color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn selection_background<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn caret_color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn selection_border_width<M>(self, width: impl IntoThemed<Length, M>) -> Self
fn selection_border_color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn selection_border_radius<M>(self, radius: impl IntoThemed<Length, M>) -> Self
fn cursor(self, cursor: Cursor) -> Self
fn background<M>(self, background: impl IntoThemed<Background, M>) -> Self
fn font_size<M>(self, size: impl IntoThemed<Length, M>) -> Self
fn font_weight(self, weight: FontWeight) -> Self
fn font_style(self, style: FontStyle) -> Self
fn letter_spacing(self, spacing: impl Into<LetterSpacing>) -> Self
fn text_align(self, align: TextAlign) -> Self
fn text_decoration(self, decoration: TextDecoration) -> Self
fn line_height(self, height: impl Into<LineHeight>) -> Self
fn margin<M>(self, margin: impl IntoThemed<Edges, M>) -> Self
fn border<M>(self, border: impl IntoThemed<Border, M>) -> Self
fn outline<M>(self, outline: impl IntoThemed<StyleValue<Outline>, M>) -> Self
fn box_shadow(self, shadows: impl Into<Vec<BoxShadow>>) -> Self
fn box_shadow_none(self) -> Self
fn min_width<M>(self, width: impl IntoThemed<Length, M>) -> Self
fn min_height<M>(self, height: impl IntoThemed<Length, M>) -> Self
fn min_size<W, H, MW, MH>(self, width: W, height: H) -> Self
fn max_width<M>(self, width: impl IntoThemed<Length, M>) -> Self
fn max_height<M>(self, height: impl IntoThemed<Length, M>) -> Self
fn max_size<W, H, MW, MH>(self, width: W, height: H) -> Self
fn display(self, display: Display) -> Self
fn position(self, position: Position) -> Self
fn top<M>(self, value: impl IntoThemed<Length, M>) -> Self
fn right<M>(self, value: impl IntoThemed<Length, M>) -> Self
fn bottom<M>(self, value: impl IntoThemed<Length, M>) -> Self
fn left<M>(self, value: impl IntoThemed<Length, M>) -> Self
Source§fn z_index(self, z_index: i32) -> Self
fn z_index(self, z_index: i32) -> Self
Paint order relative to siblings; higher values paint later, on top.
fn overflow_x(self, overflow: Overflow) -> Self
fn overflow_y(self, overflow: Overflow) -> Self
fn overflow(self, x: Overflow, y: Overflow) -> Self
fn overscroll(self, overscroll: Overscroll) -> Self
fn flex_direction(self, direction: FlexDirection) -> Self
fn flex_wrap(self, wrap: FlexWrap) -> Self
fn flex_grow(self, grow: f32) -> Self
fn flex_shrink(self, shrink: f32) -> Self
fn flex_basis<M>(self, basis: impl IntoThemed<Length, M>) -> Self
fn align_items(self, align: AlignItems) -> Self
fn align_self(self, align: AlignItems) -> Self
fn justify_content(self, justify: JustifyContent) -> Self
fn align_content(self, align: JustifyContent) -> Self
fn gap<W, H, MW, MH>(self, horizontal: W, vertical: H) -> Self
fn grid_template_columns(self, columns: impl Into<Vec<GridTrack>>) -> Self
fn grid_template_rows(self, rows: impl Into<Vec<GridTrack>>) -> Self
fn grid_column(self, column: GridPlacement) -> Self
fn grid_row(self, row: GridPlacement) -> Self
fn scrollbar_gutter(self, gutter: ScrollbarGutter) -> Self
fn scrollbar_thickness(self, thickness: f32) -> Self
fn scrollbar_min_thumb_length(self, length: f32) -> Self
fn scrollbar_thumb_color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn scrollbar_thumb_radius<M>(self, radius: impl IntoThemed<f32, M>) -> Self
fn scrollbar_track_color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn scrollbar_arrow_color<M>(self, color: impl IntoThemed<Color, M>) -> Self
fn scrollbar_thumb_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_track_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_hover_thickness(self, thickness: f32) -> Self
fn scrollbar_hover_min_thumb_length(self, length: f32) -> Self
fn scrollbar_hover_thumb_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_hover_thumb_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_hover_track_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_hover_track_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_hover_arrow_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_pressed_thickness(self, thickness: f32) -> Self
fn scrollbar_pressed_min_thumb_length(self, length: f32) -> Self
fn scrollbar_pressed_thumb_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_pressed_thumb_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_pressed_track_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_pressed_track_border_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scrollbar_pressed_arrow_color<M>( self, color: impl IntoThemed<Color, M>, ) -> Self
fn scale(self, scale: f32) -> Self
fn content_scale(self, scale: f32) -> Self
fn transition(self, transition: Transition) -> Self
fn transition_all(self, transition: Transition) -> Self
fn transition_colors(self, transition: Transition) -> Self
fn transition_opacity(self, transition: Transition) -> Self
fn transition_shadow(self, transition: Transition) -> Self
fn transition_transform(self, transition: Transition) -> Self
fn transition_none(self) -> Self
Source§impl Widget for TextBox
impl Widget for TextBox
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
fn get_key(&self) -> Option<&SmolStr>
fn is_dirty(&self) -> bool
fn set_dirty(&mut self, dirty: bool)
fn style(&self) -> &Style
fn style_mut(&mut self) -> &mut Style
fn computed_style(&self) -> &Style
fn interaction(&self) -> Option<&Interaction>
fn interaction_mut(&mut self) -> Option<&mut Interaction>
fn layout(&mut self, rect: LayoutBox)
fn layout_box(&self) -> &LayoutBox
fn debug_name(&self) -> &'static str
fn measure( &self, ctx: &mut MeasureContext<'_>, constraints: Constraints, ) -> MeasureResult
fn paint(&self, ctx: &mut PaintContext<'_>)
fn event(&mut self, event: &InputEvent, ctx: &mut EventCtx) -> EventStatus
fn content_eq(&self, other: &dyn Widget) -> bool
fn cascade_style(&mut self, parent: &Style, anim: &mut AnimationManager)
fn after_interaction_transfer(&mut self)
fn transfer_interaction_state(&mut self, old: &dyn Widget)
fn transfer_measured_state(&mut self, old: &dyn Widget)
fn cancel_text_selection(&mut self)
fn blink_interval(&self) -> Option<Duration>
Source§fn anim_id(&self) -> WidgetId
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>
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)
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_unmount(&mut self)
fn on_unmount(&mut self)
Called once, right before this widget is permanently removed from the tree.
fn children(&self) -> &[Box<dyn Widget>]
fn children_mut(&mut self) -> Option<&mut Vec<Box<dyn Widget>>>
Source§fn scroll_offset(&self) -> (f32, f32)
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))
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)>
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<'_>)
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<'_>)
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.
fn paint_box(&self, ctx: &mut PaintContext<'_>)
fn paint_edge_borders( &self, ctx: &mut PaintContext<'_>, layout: LayoutBox, b: &Border, sf: f32, )
fn paint_shadow_layer( &self, ctx: &mut PaintContext<'_>, layout: LayoutBox, radius: f32, shadow: &BoxShadow, sf: f32, )
fn paint_outline(&self, ctx: &mut PaintContext<'_>)
fn paint_focus(&self, ctx: &mut PaintContext<'_>)
Source§fn paint_top(&self, _ctx: &mut PaintContext<'_>)
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).fn hit_test(&self, point: (f32, f32)) -> bool
Source§fn blocks_children_hit_test(&self, _point: (f32, f32)) -> bool
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
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>
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).fn text_selection(&self) -> Option<(usize, usize)>
fn set_text_selection(&mut self, _range: Option<(usize, usize)>)
Source§fn text_index_at(&self, _point: (f32, f32)) -> usize
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.
fn select_all_text(&mut self)
Source§impl WidgetContent for TextBox
impl WidgetContent for TextBox
fn with_content(self, content: impl Into<SmolStr>) -> Self
Auto Trait Implementations§
impl !Freeze for TextBox
impl !RefUnwindSafe for TextBox
impl !Send for TextBox
impl !Sync for TextBox
impl !UnwindSafe for TextBox
impl Unpin for TextBox
impl UnsafeUnpin for TextBox
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
Mutably borrows from an owned value. Read more