本文へスキップ

Autocomplete

選択値を必須にせず、自由入力テキストの候補を絞り込みます。

#インポート

quickgui から Autocomplete をインポートします。

use quickgui::*;

#使い方

let mut state = AutocompleteState::new(items);
state.set_query("qui");
div().child(text(state.query()))

#構成

  • Autocomplete::root
  • Autocomplete::input
  • Autocomplete::option_part
  • Autocomplete::label
  • Autocomplete::value
  • Autocomplete::icon
  • Autocomplete::input_group
  • Autocomplete::clear
  • Autocomplete::portal
  • Autocomplete::positioner
  • Autocomplete::popup
  • Autocomplete::arrow
  • Autocomplete::status
  • Autocomplete::empty
  • Autocomplete::list
  • Autocomplete::item
  • Autocomplete::item_indicator
  • Autocomplete::group
  • Autocomplete::group_label
  • Autocomplete::collection
  • Autocomplete::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—

Configures layout for this part.

pub 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>—

Configures value for this part.

pub 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>]—

Configures items for this part.

pub 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—

Configures filter mode for this part.

pub 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—

Configures is open for this part.

pub const fn is_open(&self) -> bool
ソースを見る
is_disabledpub const fn is_disabled(&self) -> bool—

Configures is disabled for this part.

pub 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—

Configures is invalid for this part.

pub const fn is_invalid(&self) -> bool
ソースを見る
set_invalidpub fn set_invalid(&mut self, invalid: bool) -> bool—

Configures set invalid for this part.

pub 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—

Configures result count for this part.

pub fn result_count(&self) -> usize
ソースを見る
total_match_countpub fn total_match_count(&self) -> usize—

Configures total match count for this part.

pub 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—

Configures close for this part.

pub fn close(&mut self, cx: &mut EventContext) -> bool
ソースを見る
surface_idpub fn surface_id(id: impl Into<ElementId>) -> ElementId—

Configures surface id for this part.

pub 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.