AutoSuggestBox
struct · ferroui-controls · v0.5.0
struct AutoSuggestBox
A text box with a list of suggestions the application supplies (WinUI's AutoSuggestBox).
The application listens to TextChanged, raised 150 ms after the last change of the text with
its reason, and sets the items (or ItemsSource) to the suggestions; the box shows them in a
popup while it has the focus. Choosing a suggestion with the arrow keys or the pointer raises
SuggestionChosen (and puts its text, by TextMemberPath, in the box when UpdateTextOnSelect
is set); Enter, a click of a suggestion and the query button raise QuerySubmitted.
The template is the control theme of the WinUI theme (Controls/AutoSuggestBox.xaml, from
WinUI's DefaultAutoSuggestBoxStyle), with WinUI's parts: the text box TextBox, the popup
SuggestionsPopup with SuggestionsContainer and the list SuggestionsList, and the button
QueryButton. The Fluent and Simple themes have no template for it
(docs/porting/winui-controls.md, section 5.1).
Missing (docs/porting/winui-controls.md, Input): AutoMaximizeSuggestionArea,
LightDismissOverlayMode, TextBoxStyle, HeaderPlacement, the input validation of WinUI and
the placement of the list above the box when there is no room below.
Members
TYPEto_reftext_propertytext_member_path_propertyplaceholder_text_propertyupdate_text_on_select_propertyis_suggestion_list_open_propertymax_suggestion_list_height_propertyquery_icon_propertydescription_propertyconstructnewtextset_texttext_member_pathset_text_member_pathplaceholder_textset_placeholder_textupdate_text_on_selectset_update_text_on_selectis_suggestion_list_openset_is_suggestion_list_openmax_suggestion_list_heightset_max_suggestion_list_heightquery_iconset_query_icondescriptionset_descriptiontext_changedsuggestion_chosenquery_submitted
TYPE
const TYPE: &'static $crate::TypeInfo
The runtime type of this class.
to_ref
fn to_ref(self: &Self) -> $crate::Ref<AutoSuggestBox>
Returns a strong reference to this object.
text_property
fn text_property() -> &'static StyledProperty<String>
Defines the Text property: the text of the box.
text_member_path_property
fn text_member_path_property() -> &'static StyledProperty<String>
Defines the TextMemberPath property: the path of the text of a chosen suggestion; the
text of the item itself when it is empty (the default).
placeholder_text_property
fn placeholder_text_property() -> &'static StyledProperty<String>
Defines the PlaceholderText property: the text shown while the box is empty.
update_text_on_select_property
fn update_text_on_select_property() -> &'static StyledProperty<bool>
Defines the UpdateTextOnSelect property: whether choosing a suggestion puts its text
in the box. true by default.
is_suggestion_list_open_property
fn is_suggestion_list_open_property() -> &'static StyledProperty<bool>
Defines the IsSuggestionListOpen property: whether the popup of the suggestions is
open.
max_suggestion_list_height_property
fn max_suggestion_list_height_property() -> &'static StyledProperty<f64>
Defines the MaxSuggestionListHeight property: the largest height of the list of the
suggestions; infinite by default, and a negative value is infinite too.
query_icon_property
fn query_icon_property() -> &'static StyledProperty<Option<Ref<IconElement>>>
Defines the QueryIcon property: the icon of the query button; no button without one
(the default).
description_property
fn description_property() -> &'static StyledProperty<Option<BoxedValue>>
Defines the Description property: the content below the box.
construct
fn construct() -> Self
Creates the class data; see ferroui_base::FerroObject::construct.
new
fn new() -> Ref<Self>
text
fn text(self: &Self) -> String
Gets the text of the box.
set_text
fn set_text(self: &Self, value: impl Into<String>)
Sets the text of the box.
text_member_path
fn text_member_path(self: &Self) -> String
Gets the path of the text of a chosen suggestion.
set_text_member_path
fn set_text_member_path(self: &Self, value: impl Into<String>)
Sets the path of the text of a chosen suggestion.
placeholder_text
fn placeholder_text(self: &Self) -> String
Gets the text shown while the box is empty.
set_placeholder_text
fn set_placeholder_text(self: &Self, value: impl Into<String>)
Sets the text shown while the box is empty.
update_text_on_select
fn update_text_on_select(self: &Self) -> bool
Gets whether choosing a suggestion puts its text in the box.
set_update_text_on_select
fn set_update_text_on_select(self: &Self, value: bool)
Sets whether choosing a suggestion puts its text in the box.
is_suggestion_list_open
fn is_suggestion_list_open(self: &Self) -> bool
Gets whether the popup of the suggestions is open.
set_is_suggestion_list_open
fn set_is_suggestion_list_open(self: &Self, value: bool)
Opens or closes the popup of the suggestions; opening it focuses the text box.
max_suggestion_list_height
fn max_suggestion_list_height(self: &Self) -> f64
Gets the largest height of the list of the suggestions.
set_max_suggestion_list_height
fn set_max_suggestion_list_height(self: &Self, value: f64)
Sets the largest height of the list of the suggestions.
query_icon
fn query_icon(self: &Self) -> Option<Ref<IconElement>>
Gets the icon of the query button.
set_query_icon
fn set_query_icon(self: &Self, value: Option<Ref<IconElement>>)
Sets the icon of the query button.
description
fn description(self: &Self) -> Option<BoxedValue>
Gets the content below the box.
set_description
fn set_description(self: &Self, value: Option<BoxedValue>)
Sets the content below the box.
text_changed
fn text_changed(self: &Self, handler: impl Fn(&AutoSuggestBoxTextChangedEventArgs) -> () + 'static) -> Subscription
Adds a handler of the TextChanged event, raised 150 ms after the last change of the text.
Dropping the returned guard removes the handler; Subscription::detach keeps it for the
life of the box.
suggestion_chosen
fn suggestion_chosen(self: &Self, handler: impl Fn(&AutoSuggestBoxSuggestionChosenEventArgs) -> () + 'static) -> Subscription
Adds a handler of the SuggestionChosen event. Dropping the returned guard removes the
handler; Subscription::detach keeps it for the life of the box.
query_submitted
fn query_submitted(self: &Self, handler: impl Fn(&AutoSuggestBoxQuerySubmittedEventArgs) -> () + 'static) -> Subscription
Adds a handler of the QuerySubmitted event. Dropping the returned guard removes the
handler; Subscription::detach keeps it for the life of the box.
Trait implementations
SendSyncFreezeUnsafeUnpinUnpinUnwindSafeRefUnwindSafeTemplatedControlImplExtHeaderedItemsControlImplExtControlImplExtItemsControlImplExtBorrow<T>BorrowMut<T>Into<U>From<T>TryInto<U>TryFrom<U>ReceiverAnyInputElementImplExtInteractiveImplExtLayoutableImplExtFerroObjectImplExtStyledElementImplExtClassDefaultsVisualImplExtErasedDestructorIntoEitherDerefUpcast<T>Upcast<AutoSuggestBox>StaticTypeObjectTypeSubclassable<T>DefaultConstructibleStyledElementImplVisualImplLayoutableImplInteractiveImplHeaderedItemsControlImplFerroObjectImplControlImplItemsControlImplInputElementImplTemplatedControlImplDrop
Availability
Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.