pub struct TextBox {Show 28 fields
pub controller: TextEditingControllerRef,
pub focus_node: Option<FocusNodeRef>,
pub header: Option<WidgetRef>,
pub description: Option<WidgetRef>,
pub placeholder_text: String,
pub is_enabled: bool,
pub font_size: Option<f64>,
pub padding: Option<[f64; 4]>,
pub corner_radius: Option<f64>,
pub foreground: Option<Color>,
pub background: Option<Brush>,
pub border_brush: Option<Brush>,
pub selection_highlight_color: Option<Color>,
pub max_length: Option<i32>,
pub input_formatters: Vec<TextInputFormatterRef>,
pub autofocus: bool,
pub show_cursor: Option<bool>,
pub context_menu_builder: Option<EditableTextContextMenuBuilder>,
pub is_read_only: bool,
pub accepts_return: bool,
pub text_wrapping: TextWrapping,
pub horizontal_scroll_bar_visibility: ScrollBarVisibility,
pub max_lines: Option<i32>,
pub text_alignment: TextAlign,
pub placeholder_foreground: Option<Color>,
pub text_changed: Option<TextChangedCallback>,
pub selection_changed: Option<TextSelectionChangedCallback>,
pub key: Option<KeyRef>,
}Expand description
The WinUI TextBox control with its default Fluent template.
Fields§
§controller: TextEditingControllerRefOwns the text, selection and composing range; the caller retains and disposes it.
focus_node: Option<FocusNodeRef>An optional caller-owned focus node; otherwise the control creates one.
header: Option<WidgetRef>Content above the editor, with the source header margin.
description: Option<WidgetRef>Supporting content below the editor.
placeholder_text: StringText displayed while the controller is empty.
is_enabled: boolWhether the editor accepts pointer and keyboard input.
font_size: Option<f64>The editor font size and basis of the helper-button width threshold; the theme’s ControlContentThemeFontSize when None.
padding: Option<[f64; 4]>Editor padding in left, top, right, bottom order; the theme’s TextControlThemePadding when None.
corner_radius: Option<f64>The template border and helper-button corner radius.
foreground: Option<Color>Overrides the normal editor foreground; visual states use their source theme resources.
background: Option<Brush>Overrides the normal editor background.
border_brush: Option<Brush>Overrides the normal editor border brush.
selection_highlight_color: Option<Color>Overrides the selection fill while the editor has focus.
max_length: Option<i32>Limits user edits through the native length formatter; programmatic assignments remain unrestricted.
input_formatters: Vec<TextInputFormatterRef>Native formatters applied to user edits, following Flutter composition and undo behavior.
autofocus: boolRequests initial keyboard focus through the native editor.
show_cursor: Option<bool>Whether the caret is drawn while the box has the focus; Flutter’s TextField.showCursor,
which XAML’s TextBox has no property for. None draws it unless the box is read-only.
A box that hides it still takes what is typed.
Overrides the desktop text-command menu.
is_read_only: boolAllows selection and copying while preventing edits.
accepts_return: boolAccepts line breaks and enables native wrapped multiline editing.
A multiline box fills the height its parent gives it, as WinUI’s default
VerticalAlignment="Stretch" does, and its editor scrolls once the text passes it; in an
unbounded parent it grows with its text.
text_wrapping: TextWrappingWraps text independently of accepting Enter; with NoWrap, a multiline box keeps each line whole and scrolls sideways.
horizontal_scroll_bar_visibility: ScrollBarVisibilityScrollViewer.HorizontalScrollBarVisibility: how a multiline box that does not wrap scrolls its lines sideways.
max_lines: Option<i32>Limits the visible height in lines for a multiline editor, which grows with its text from one line up to it; past it, the content scrolls vertically. Setting it leaves the editor at that height instead of filling the box; leave it unset for a box that fills its pane.
text_alignment: TextAlignAlignment of editor and placeholder text.
placeholder_foreground: Option<Color>Overrides the placeholder foreground in every visual state.
text_changed: Option<TextChangedCallback>Receives user text edits and clear-button actions; listen to the controller for all assignments.
selection_changed: Option<TextSelectionChangedCallback>Receives native user selection changes after the controller updates.
key: Option<KeyRef>Identity retained across parent rebuilds.
Implementations§
Source§impl TextBox
impl TextBox
Sourcepub fn new(controller: TextEditingControllerRef) -> Self
pub fn new(controller: TextEditingControllerRef) -> Self
Creates an editor using a caller-owned native editing controller.
Sourcepub fn focus_node(self, value: FocusNodeRef) -> Self
pub fn focus_node(self, value: FocusNodeRef) -> Self
Sets FocusNode.
Sourcepub fn header<K>(self, value: impl IntoWidget<K>) -> Self
pub fn header<K>(self, value: impl IntoWidget<K>) -> Self
Sets Header.
Sourcepub fn description<K>(self, value: impl IntoWidget<K>) -> Self
pub fn description<K>(self, value: impl IntoWidget<K>) -> Self
Sets Description.
Sourcepub fn placeholder_text(self, value: impl Into<String>) -> Self
pub fn placeholder_text(self, value: impl Into<String>) -> Self
Sets PlaceholderText.
Sourcepub fn is_enabled(self, value: bool) -> Self
pub fn is_enabled(self, value: bool) -> Self
Sets IsEnabled.
Sourcepub fn corner_radius(self, value: f64) -> Self
pub fn corner_radius(self, value: f64) -> Self
Sets CornerRadius.
Sourcepub fn foreground(self, value: Color) -> Self
pub fn foreground(self, value: Color) -> Self
Sets Foreground.
Sourcepub fn background(self, value: Brush) -> Self
pub fn background(self, value: Brush) -> Self
Sets Background.
Sourcepub fn border_brush(self, value: Brush) -> Self
pub fn border_brush(self, value: Brush) -> Self
Sets BorderBrush.
Sourcepub fn selection_highlight_color(self, value: Color) -> Self
pub fn selection_highlight_color(self, value: Color) -> Self
Sets SelectionHighlightColor.
Sourcepub fn max_length(self, value: i32) -> Self
pub fn max_length(self, value: i32) -> Self
Sets MaxLength.
Sourcepub fn input_formatters(self, value: Vec<TextInputFormatterRef>) -> Self
pub fn input_formatters(self, value: Vec<TextInputFormatterRef>) -> Self
Sets InputFormatters.
Sets ContextMenuBuilder.
Sourcepub fn is_read_only(self, value: bool) -> Self
pub fn is_read_only(self, value: bool) -> Self
Sets IsReadOnly.
Sourcepub fn accepts_return(self, value: bool) -> Self
pub fn accepts_return(self, value: bool) -> Self
Sets AcceptsReturn.
Sourcepub fn text_wrapping(self, value: TextWrapping) -> Self
pub fn text_wrapping(self, value: TextWrapping) -> Self
Sets TextWrapping.
Sourcepub fn horizontal_scroll_bar_visibility(
self,
value: ScrollBarVisibility,
) -> Self
pub fn horizontal_scroll_bar_visibility( self, value: ScrollBarVisibility, ) -> Self
Sets ScrollViewer.HorizontalScrollBarVisibility.
Sourcepub fn text_alignment(self, value: TextAlign) -> Self
pub fn text_alignment(self, value: TextAlign) -> Self
Sets TextAlignment.
Sourcepub fn show_cursor(self, value: bool) -> Self
pub fn show_cursor(self, value: bool) -> Self
Whether the caret is drawn while the box has the focus: Flutter’s TextField.showCursor.
Sourcepub fn placeholder_foreground(self, value: Color) -> Self
pub fn placeholder_foreground(self, value: Color) -> Self
Sets PlaceholderForeground.
Sourcepub fn text_changed(self, value: impl Fn(&mut App, String) + 'static) -> Self
pub fn text_changed(self, value: impl Fn(&mut App, String) + 'static) -> Self
Sets TextChanged.
Sourcepub fn selection_changed(
self,
value: impl Fn(&mut App, TextSelection, Option<SelectionChangedCause>) + 'static,
) -> Self
pub fn selection_changed( self, value: impl Fn(&mut App, TextSelection, Option<SelectionChangedCause>) + 'static, ) -> Self
Sets SelectionChanged.
Trait Implementations§
Source§impl StatefulWidget for TextBox
impl StatefulWidget for TextBox
Source§type State = TextBoxState
type State = TextBoxState
Source§fn create_state(&self) -> TextBoxState
fn create_state(&self) -> TextBoxState
Source§fn debug_fill_properties(
&self,
_app: &App,
properties: &mut DiagnosticPropertiesBuilder,
)
fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )
debugFillProperties: the properties a dump shows for this widget, in Dart’s
order. Dart’s Widget base only sets the dense tree style, which the framework does.Source§fn as_preferred_size_widget(
&self,
) -> Option<&(dyn PreferredSizeWidget + 'static)>
fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Widget::type_name. A stateful form another widget kind becomes (an animated or
status transition widget) names the widget it wraps.Auto Trait Implementations§
impl !RefUnwindSafe for TextBox
impl !Send for TextBox
impl !Sync for TextBox
impl !UnwindSafe for TextBox
impl Forget for TextBox
impl Freeze for TextBoxwhere
NonZero<u32>: Freeze,
&'static TextEditingControllerVTable: Freeze,
*const RcInner<Keep> is !null: Freeze,
PhantomData<RcInner<Keep>>: Freeze,
&'static FocusNodeVTable: Freeze,
*const RcInner<dyn Widget> is !null: Freeze,
PhantomData<RcInner<dyn Widget>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<TextInputFormatterRef>: Freeze,
*const RcInner<dyn Fn(&mut App, AnyElement, Handle<EditableTextState>) -> Rc<dyn Widget>> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Handle<EditableTextState>) -> Rc<dyn Widget>>>: Freeze,
*const RcInner<dyn Fn(&mut App, String)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, String)>>: Freeze,
*const RcInner<dyn Fn(&mut App, TextSelection, Option<SelectionChangedCause>)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&mut App, TextSelection, Option<SelectionChangedCause>)>>: Freeze,
*const RcInner<dyn Key> is !null: Freeze,
PhantomData<RcInner<dyn Key>>: Freeze,
impl Move for TextBox
impl Unpin for TextBoxwhere
NonZero<u32>: Unpin,
&'static TextEditingControllerVTable: Unpin,
Rc<Keep>: Unpin,
&'static FocusNodeVTable: Unpin,
Rc<dyn Widget>: Unpin,
*const u8 is !null: Unpin,
Rc<dyn TextInputFormatter>: Unpin,
Rc<dyn Fn(&mut App, AnyElement, Handle<EditableTextState>) -> Rc<dyn Widget>>: Unpin,
Rc<dyn Fn(&mut App, String)>: Unpin,
Rc<dyn Fn(&mut App, TextSelection, Option<SelectionChangedCause>)>: Unpin,
Rc<dyn Key>: Unpin,
impl UnsafeUnpin for TextBoxwhere
NonZeroU32Inner: UnsafeUnpin,
&'static TextEditingControllerVTable: UnsafeUnpin,
*const RcInner<Keep> is !null: UnsafeUnpin,
PhantomData<RcInner<Keep>>: UnsafeUnpin,
&'static FocusNodeVTable: UnsafeUnpin,
*const RcInner<dyn Widget> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Widget>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<TextInputFormatterRef>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, AnyElement, Handle<EditableTextState>) -> Rc<dyn Widget>> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, AnyElement, Handle<EditableTextState>) -> Rc<dyn Widget>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, String)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, String)>>: UnsafeUnpin,
*const RcInner<dyn Fn(&mut App, TextSelection, Option<SelectionChangedCause>)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&mut App, TextSelection, Option<SelectionChangedCause>)>>: UnsafeUnpin,
*const RcInner<dyn Key> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Key>>: UnsafeUnpin,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
impl<W> IntoWidget<StatefulKind> for Wwhere
W: StatefulWidget,
Source§fn into_widget(self) -> Rc<dyn Widget>
fn into_widget(self) -> Rc<dyn Widget>
creation_location.