Skip to main content

AutoSuggestBox

Struct AutoSuggestBox 

Source
pub struct AutoSuggestBox<T: Display + 'static> {
Show 17 fields pub controller: TextEditingControllerRef, pub items_source: Rc<[T]>, pub text_member_path: Option<AutoSuggestBoxTextMember<T>>, pub item_template: Option<AutoSuggestBoxItemTemplate<T>>, pub placeholder_text: String, pub header: Option<WidgetRef>, pub description: Option<WidgetRef>, pub query_icon: Option<WidgetRef>, pub max_suggestion_list_height: f64, pub is_suggestion_list_open: Option<bool>, pub is_suggestion_list_open_changed: Option<AutoSuggestBoxOpenChangedHandler>, pub update_text_on_select: bool, pub auto_maximize_suggestion_area: bool, pub text_changed: Option<AutoSuggestBoxTextChangedHandler>, pub suggestion_chosen: Option<AutoSuggestBoxSuggestionChosenHandler<T>>, pub query_submitted: Option<AutoSuggestBoxQuerySubmittedHandler<T>>, pub key: Option<KeyRef>,
}
Expand description

XAML AutoSuggestBox: a text box whose text lives in the application’s controller, with the suggestions the application sets in items_source as it hears text_changed.

Fields§

§controller: TextEditingControllerRef

TextBox’s text: Text.

§items_source: Rc<[T]>

ItemsSource: the suggestions.

§text_member_path: Option<AutoSuggestBoxTextMember<T>>

TextMemberPath: the text a chosen suggestion puts in the box; the item’s Display when unset.

§item_template: Option<AutoSuggestBoxItemTemplate<T>>

ItemTemplate: what the list shows for an item; its Display when unset.

§placeholder_text: String

PlaceholderText.

§header: Option<WidgetRef>

Header.

§description: Option<WidgetRef>

Description.

§query_icon: Option<WidgetRef>

QueryIcon: the query button’s content; no query button when unset. WinUI’s SymbolIcon takes AutoSuggestBoxIconFontSize; the kit’s icons bring their own size.

§max_suggestion_list_height: f64

MaxSuggestionListHeight: unbounded by default, and all the room there is when negative.

§is_suggestion_list_open: Option<bool>

IsSuggestionListOpen, when the application owns it, and where the box asks to change it.

§is_suggestion_list_open_changed: Option<AutoSuggestBoxOpenChangedHandler>§update_text_on_select: bool

UpdateTextOnSelect: whether moving to a suggestion puts its text in the box.

§auto_maximize_suggestion_area: bool

AutoMaximizeSuggestionArea: read only while an on-screen keyboard covers the window, which no platform of the kit reports.

§text_changed: Option<AutoSuggestBoxTextChangedHandler>

TextChanged, 150 ms after the last change of the text.

§suggestion_chosen: Option<AutoSuggestBoxSuggestionChosenHandler<T>>

SuggestionChosen.

§query_submitted: Option<AutoSuggestBoxQuerySubmittedHandler<T>>

QuerySubmitted.

§key: Option<KeyRef>

Identity retained across rebuilds.

Implementations§

Source§

impl<T: Display + 'static> AutoSuggestBox<T>

Source

pub fn new(controller: TextEditingControllerRef) -> Self

Creates a box editing controller’s text, with no suggestions.

Source

pub fn items_source(self, items: Vec<T>) -> Self

Sets ItemsSource.

Source

pub fn text_member_path(self, text: impl Fn(&T) -> String + 'static) -> Self

Sets TextMemberPath.

Source

pub fn item_template( self, template: impl Fn(&mut App, BuildContext, &T) -> WidgetRef + 'static, ) -> Self

Sets ItemTemplate.

Source

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

Sets PlaceholderText.

Source

pub fn header<K>(self, value: impl IntoWidget<K>) -> Self

Sets Header.

Source

pub fn description<K>(self, value: impl IntoWidget<K>) -> Self

Sets Description.

Source

pub fn query_icon<K>(self, value: impl IntoWidget<K>) -> Self

Sets QueryIcon.

Source

pub fn max_suggestion_list_height(self, value: f64) -> Self

Sets MaxSuggestionListHeight.

Source

pub fn is_suggestion_list_open( self, open: bool, changed: impl Fn(&mut App, bool) + 'static, ) -> Self

Gives the application IsSuggestionListOpen: the box shows open and asks for changes through changed. Opening it moves the focus to the box, as the property’s setter does.

Source

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

Sets UpdateTextOnSelect.

Source

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

Sets AutoMaximizeSuggestionArea.

Source

pub fn text_changed( self, handler: impl Fn(&mut App, &AutoSuggestBoxTextChangedEventArgs) + 'static, ) -> Self

Sets TextChanged.

Source

pub fn suggestion_chosen( self, handler: impl Fn(&mut App, &AutoSuggestBoxSuggestionChosenEventArgs<T>) + 'static, ) -> Self

Sets SuggestionChosen.

Source

pub fn query_submitted( self, handler: impl Fn(&mut App, &AutoSuggestBoxQuerySubmittedEventArgs<T>) + 'static, ) -> Self

Sets QuerySubmitted.

Source

pub fn key(self, key: KeyRef) -> Self

Sets the identity retained across rebuilds.

Trait Implementations§

Source§

impl<T: Display + 'static> Clone for AutoSuggestBox<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Display + 'static> Debug for AutoSuggestBox<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Display + 'static> StatefulWidget for AutoSuggestBox<T>

Source§

type State = AutoSuggestBoxState<T>

The state this widget creates.
Source§

fn key(&self) -> Option<&KeyRef>

Source§

fn create_state(&self) -> AutoSuggestBoxState<T>

Creates the mutable state for this widget at a given location in the tree. Read more
Source§

fn debug_fill_properties( &self, _app: &App, properties: &mut DiagnosticPropertiesBuilder, )

Dart’s 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 debug_check_constructor(&self)

Source§

fn as_preferred_size_widget( &self, ) -> Option<&(dyn PreferredSizeWidget + 'static)>

Source§

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

See 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<T> !RefUnwindSafe for AutoSuggestBox<T>

§

impl<T> !Send for AutoSuggestBox<T>

§

impl<T> !Sync for AutoSuggestBox<T>

§

impl<T> !UnwindSafe for AutoSuggestBox<T>

§

impl<T> Forget for AutoSuggestBox<T>

§

impl<T> Freeze for AutoSuggestBox<T>
where NonZero<u32>: Freeze, &'static TextEditingControllerVTable: Freeze, *const RcInner<Keep> is !null: Freeze, PhantomData<RcInner<Keep>>: Freeze, *const RcInner<[T]> is !null: Freeze, PhantomData<RcInner<[T]>>: Freeze, *const RcInner<dyn Fn(&T) -> String> is !null: Freeze, PhantomData<RcInner<dyn Fn(&T) -> String>>: Freeze, *const RcInner<dyn Fn(&mut App, AnyElement, &T) -> Rc<dyn Widget>> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, &T) -> Rc<dyn Widget>>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const RcInner<dyn Widget> is !null: Freeze, PhantomData<RcInner<dyn Widget>>: Freeze, *const RcInner<dyn Fn(&mut App, bool)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: Freeze, *const RcInner<dyn Fn(&mut App, &AutoSuggestBoxTextChangedEventArgs)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, &AutoSuggestBoxTextChangedEventArgs)>>: Freeze, *const RcInner<dyn Fn(&mut App, &AutoSuggestBoxSuggestionChosenEventArgs<T>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, &AutoSuggestBoxSuggestionChosenEventArgs<T>)>>: Freeze, *const RcInner<dyn Fn(&mut App, &AutoSuggestBoxQuerySubmittedEventArgs<T>)> is !null: Freeze, PhantomData<RcInner<dyn Fn(&mut App, &AutoSuggestBoxQuerySubmittedEventArgs<T>)>>: Freeze, *const RcInner<dyn Key> is !null: Freeze, PhantomData<RcInner<dyn Key>>: Freeze,

§

impl<T> Move for AutoSuggestBox<T>

§

impl<T> Unpin for AutoSuggestBox<T>
where NonZero<u32>: Unpin, &'static TextEditingControllerVTable: Unpin, Rc<Keep>: Unpin, Rc<[T]>: Unpin, Rc<dyn Fn(&T) -> String>: Unpin, Rc<dyn Fn(&mut App, AnyElement, &T) -> Rc<dyn Widget>>: Unpin, *const u8 is !null: Unpin, Rc<dyn Widget>: Unpin, Rc<dyn Fn(&mut App, bool)>: Unpin, Rc<dyn Fn(&mut App, &AutoSuggestBoxTextChangedEventArgs)>: Unpin, Rc<dyn Fn(&mut App, &AutoSuggestBoxSuggestionChosenEventArgs<T>)>: Unpin, Rc<dyn Fn(&mut App, &AutoSuggestBoxQuerySubmittedEventArgs<T>)>: Unpin, Rc<dyn Key>: Unpin,

§

impl<T> UnsafeUnpin for AutoSuggestBox<T>
where NonZeroU32Inner: UnsafeUnpin, &'static TextEditingControllerVTable: UnsafeUnpin, *const RcInner<Keep> is !null: UnsafeUnpin, PhantomData<RcInner<Keep>>: UnsafeUnpin, *const RcInner<[T]> is !null: UnsafeUnpin, PhantomData<RcInner<[T]>>: UnsafeUnpin, *const RcInner<dyn Fn(&T) -> String> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&T) -> String>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, AnyElement, &T) -> Rc<dyn Widget>> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, AnyElement, &T) -> Rc<dyn Widget>>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const RcInner<dyn Widget> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Widget>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, bool)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, bool)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, &AutoSuggestBoxTextChangedEventArgs)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, &AutoSuggestBoxTextChangedEventArgs)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, &AutoSuggestBoxSuggestionChosenEventArgs<T>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, &AutoSuggestBoxSuggestionChosenEventArgs<T>)>>: UnsafeUnpin, *const RcInner<dyn Fn(&mut App, &AutoSuggestBoxQuerySubmittedEventArgs<T>)> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Fn(&mut App, &AutoSuggestBoxQuerySubmittedEventArgs<T>)>>: UnsafeUnpin, *const RcInner<dyn Key> is !null: UnsafeUnpin, PhantomData<RcInner<dyn Key>>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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<W> IntoWidget<StatefulKind> for W
where W: StatefulWidget,

Source§

fn into_widget(self) -> Rc<dyn Widget>

The widget as a tree node, made where this is called: its creation_location.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>