Autocomplete
選択値を必須にせず、自由入力テキストの候補を絞り込みます。
#インポート
quickgui から Autocomplete をインポートします。
use quickgui::*;#使い方
let mut state = AutocompleteState::new(items);
state.set_query("qui");
div().child(text(state.query()))#構成
Autocomplete::rootAutocomplete::inputAutocomplete::option_partAutocomplete::labelAutocomplete::valueAutocomplete::iconAutocomplete::input_groupAutocomplete::clearAutocomplete::portalAutocomplete::positionerAutocomplete::popupAutocomplete::arrowAutocomplete::statusAutocomplete::emptyAutocomplete::listAutocomplete::itemAutocomplete::item_indicatorAutocomplete::groupAutocomplete::group_labelAutocomplete::collectionAutocomplete::separator
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
AutocompleteState
ソースを見るpub fn new(items: impl IntoIterator<Item = PickerItem<T>>) -> Result<Self, PickerError>with_layoutpub fn with_layout(mut self, layout: AutocompletePopoverLayout) -> Self—
Configures with layout for this part.
pub fn with_layout(mut self, layout: AutocompletePopoverLayout) -> Selfソースを見るwith_filter_modepub fn with_filter_mode(mut self, filter_mode: PickerFilterMode) -> Self—
Configures with filter mode for this part.
pub fn with_filter_mode(mut self, filter_mode: PickerFilterMode) -> Selfソースを見るwith_filterpub fn with_filter(mut self, filter: PickerFilter) -> Self—
Install an application-supplied filter predicate before a runtime context exists. This is Base UI's `filter` prop. The predicate replaces [`Self::filter_mode`] entirely; [`Self::set_filter`] passing `None` restores it.
pub fn with_filter(mut self, filter: PickerFilter) -> Selfソースを見るwith_valuepub fn with_value(mut self, value: impl Into<Arc<str>>) -> Self—
Set the initial free-form value before a runtime context exists. This is the constructor-time equivalent of [`Self::set_value`]: a state that has never been mounted owns no popover to synchronize, so no [`EventContext`] is needed. The value is bounded by [`MAX_AUTOCOMPLETE_VALUE_BYTES`] exactly as it is at runtime.
pub fn with_value(mut self, value: impl Into<Arc<str>>) -> Selfソースを見るlayoutpub const fn layout(&self) -> AutocompletePopoverLayout—
set_layoutpub fn set_layout(&mut self, layout: AutocompletePopoverLayout, cx: &mut EventContext) -> bool—
Replace native popover geometry, closing an open fixed-size child first.
pub fn set_layout(&mut self, layout: AutocompletePopoverLayout, cx: &mut EventContext) -> boolソースを見るselection_behaviorpub const fn selection_behavior(&self) -> AutocompleteSelectionBehavior—
Configures selection behavior for this part.
pub const fn selection_behavior(&self) -> AutocompleteSelectionBehaviorソースを見るset_selection_behaviorpub fn set_selection_behavior(&mut self, behavior: AutocompleteSelectionBehavior) -> bool—
Configures set selection behavior for this part.
pub fn set_selection_behavior(&mut self, behavior: AutocompleteSelectionBehavior) -> boolソースを見るvaluepub fn value(&self) -> &Arc<str>—
set_valuepub fn set_value(&mut self, value: impl Into<Arc<str>>, cx: &mut EventContext) -> bool—
Replace the free-form value and recompute or forward the bounded suggestion query.
pub fn set_value(&mut self, value: impl Into<Arc<str>>, cx: &mut EventContext) -> boolソースを見るitemspub fn items(&self) -> &[PickerItem<T>]—
set_itemspub fn set_items( &mut self, items: impl IntoIterator<Item = PickerItem<T>>, cx: &mut EventContext, ) -> Result<(), PickerError>—
Atomically replace suggestions and update an open child without reopening its surface.
pub fn set_items( &mut self, items: impl IntoIterator<Item = PickerItem<T>>, cx: &mut EventContext, ) -> Result<(), PickerError>ソースを見るfilter_modepub const fn filter_mode(&self) -> PickerFilterMode—
set_filter_modepub fn set_filter_mode( &mut self, filter_mode: PickerFilterMode, cx: &mut EventContext, ) -> bool—
Configures set filter mode for this part.
pub fn set_filter_mode( &mut self, filter_mode: PickerFilterMode, cx: &mut EventContext, ) -> boolソースを見るfilterpub fn filter(&self) -> Option<&PickerFilter>—
The application-supplied filter predicate, when one is installed.
pub fn filter(&self) -> Option<&PickerFilter>ソースを見るset_filterpub fn set_filter(&mut self, filter: Option<PickerFilter>, cx: &mut EventContext) -> bool—
Replace the built-in filter policy with an application-supplied predicate. Passing `None` restores [`Self::filter_mode`]. The open suggestion surface, if any, is resynchronized exactly once.
pub fn set_filter(&mut self, filter: Option<PickerFilter>, cx: &mut EventContext) -> boolソースを見るpopover_windowpub const fn popover_window(&self) -> Option<WindowHandle>—
Configures popover window for this part.
pub const fn popover_window(&self) -> Option<WindowHandle>ソースを見るis_openpub const fn is_open(&self) -> bool—
is_disabledpub const fn is_disabled(&self) -> bool—
set_disabledpub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> bool—
Configures set disabled for this part.
pub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> boolソースを見るis_invalidpub const fn is_invalid(&self) -> bool—
set_invalidpub fn set_invalid(&mut self, invalid: bool) -> bool—
validation_messagepub fn validation_message(&self) -> Option<&Arc<str>>—
Configures validation message for this part.
pub fn validation_message(&self) -> Option<&Arc<str>>ソースを見るset_validation_messagepub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> bool—
Configures set validation message for this part.
pub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> boolソースを見るclear_validation_messagepub fn clear_validation_message(&mut self) -> bool—
Configures clear validation message for this part.
pub fn clear_validation_message(&mut self) -> boolソースを見るresult_countpub fn result_count(&self) -> usize—
total_match_countpub fn total_match_count(&self) -> usize—
active_result_indexpub fn active_result_index(&self) -> Option<usize>—
Configures active result index for this part.
pub fn active_result_index(&self) -> Option<usize>ソースを見るactive_source_indexpub fn active_source_index(&self) -> Option<usize>—
Configures active source index for this part.
pub fn active_source_index(&self) -> Option<usize>ソースを見るclosepub fn close(&mut self, cx: &mut EventContext) -> bool—
surface_idpub fn surface_id(id: impl Into<ElementId>) -> ElementId—
option_id_for_sourcepub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>—
Configures option id for source for this part.
pub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>ソースを見るAutocompleteState::element
ソースを見るpub fn element<V, PopoverRoot, RenderOption, ValueChanged, Select>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: fn(&mut V) -> &mut AutocompleteState<T>, input: Element, popover_root: PopoverRoot, render_option: RenderOption, value_changed: ValueChanged, select: Select, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(AutocompleteListState) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, AutocompleteOptionState) -> Element + Clone + 'static, ValueChanged: Fn(&mut V, Arc<str>, &mut EventContext) + Clone + 'static, Select: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the complete unstyled interaction from caller-owned input, popover, and row elements.
AutocompleteState::element_with
ソースを見るpub fn element_with<V, PopoverRoot, RenderOption, ValueChanged, Select>( &mut self, cx: &mut ViewContext<'_, V>, id: impl Into<ElementId>, label: impl Into<Arc<str>>, access: StateAccessor<V, AutocompleteState<T>>, input: Element, popover_root: PopoverRoot, render_option: RenderOption, value_changed: ValueChanged, select: Select, ) -> Element where V: 'static, T: Clone + 'static, PopoverRoot: Fn(AutocompleteListState) -> Element + Clone + 'static, RenderOption: Fn(&PickerItem<T>, AutocompleteOptionState) -> Element + Clone + 'static, ValueChanged: Fn(&mut V, Arc<str>, &mut EventContext) + Clone + 'static, Select: Fn(&mut V, T, &mut EventContext) + Clone + 'static,Build the autocomplete against a per-instance retained-state accessor. A host that renders many declared autocompletes through one view passes an accessor that captures which [`AutocompleteState`] each registered listener resolves.
