pub struct AutocompleteState<T> { /* private fields */ }Expand description
Controlled, free-form autocomplete state with an overflow-capable native suggestion panel.
The owner input remains the native key and IME target. The visual child panel is never key, while a bounded semantic listbox proxy remains in the owner’s AccessKit tree. Closed state owns no native window, entity, timer, task, observer, renderer, or scheduler source.
Implementations§
Source§impl<T> AutocompleteState<T>
impl<T> AutocompleteState<T>
pub fn new( items: impl IntoIterator<Item = PickerItem<T>>, ) -> Result<Self, PickerError>
pub fn with_layout(self, layout: AutocompletePopoverLayout) -> Self
pub fn with_filter_mode(self, filter_mode: PickerFilterMode) -> Self
Sourcepub fn with_filter(self, filter: PickerFilter) -> Self
pub fn with_filter(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.
Sourcepub fn with_value(self, value: impl Into<Arc<str>>) -> Self
pub fn with_value(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 const fn layout(&self) -> AutocompletePopoverLayout
Sourcepub fn set_layout(
&mut self,
layout: AutocompletePopoverLayout,
cx: &mut EventContext,
) -> bool
pub fn set_layout( &mut self, layout: AutocompletePopoverLayout, cx: &mut EventContext, ) -> bool
Replace native popover geometry, closing an open fixed-size child first.
pub const fn selection_behavior(&self) -> AutocompleteSelectionBehavior
pub fn set_selection_behavior( &mut self, behavior: AutocompleteSelectionBehavior, ) -> bool
pub fn value(&self) -> &Arc<str> ⓘ
Sourcepub fn set_value(
&mut self,
value: impl Into<Arc<str>>,
cx: &mut EventContext,
) -> bool
pub 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 items(&self) -> &[PickerItem<T>]
Sourcepub fn set_items(
&mut self,
items: impl IntoIterator<Item = PickerItem<T>>,
cx: &mut EventContext,
) -> Result<(), PickerError>
pub 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 const fn filter_mode(&self) -> PickerFilterMode
pub fn set_filter_mode( &mut self, filter_mode: PickerFilterMode, cx: &mut EventContext, ) -> bool
Sourcepub fn filter(&self) -> Option<&PickerFilter>
pub fn filter(&self) -> Option<&PickerFilter>
The application-supplied filter predicate, when one is installed.
Sourcepub fn set_filter(
&mut self,
filter: Option<PickerFilter>,
cx: &mut EventContext,
) -> bool
pub 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 const fn popover_window(&self) -> Option<WindowHandle>
pub const fn is_open(&self) -> bool
pub const fn is_disabled(&self) -> bool
pub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> bool
pub const fn is_invalid(&self) -> bool
pub fn set_invalid(&mut self, invalid: bool) -> bool
pub fn validation_message(&self) -> Option<&Arc<str>>
pub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> bool
pub fn clear_validation_message(&mut self) -> bool
pub fn result_count(&self) -> usize
pub fn total_match_count(&self) -> usize
pub fn active_result_index(&self) -> Option<usize>
pub fn active_source_index(&self) -> Option<usize>
pub fn close(&mut self, cx: &mut EventContext) -> bool
pub fn surface_id(id: impl Into<ElementId>) -> ElementId
pub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>
Sourcepub 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,
) -> Elementwhere
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,
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,
) -> Elementwhere
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.
Sourcepub 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,
) -> Elementwhere
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,
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,
) -> Elementwhere
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.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for AutocompleteState<T>
impl<T> !Send for AutocompleteState<T>
impl<T> !Sync for AutocompleteState<T>
impl<T> !UnwindSafe for AutocompleteState<T>
impl<T> Forget for AutocompleteState<T>
impl<T> Freeze for AutocompleteState<T>
impl<T> Move for AutocompleteState<T>
impl<T> Unpin for AutocompleteState<T>
impl<T> UnsafeUnpin for AutocompleteState<T>
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.