Skip to main content

AutocompleteState

Struct AutocompleteState 

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

Source

pub fn new( items: impl IntoIterator<Item = PickerItem<T>>, ) -> Result<Self, PickerError>

Source

pub fn with_layout(self, layout: AutocompletePopoverLayout) -> Self

Source

pub fn with_filter_mode(self, filter_mode: PickerFilterMode) -> Self

Source

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.

Source

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.

Source

pub const fn layout(&self) -> AutocompletePopoverLayout

Source

pub fn set_layout( &mut self, layout: AutocompletePopoverLayout, cx: &mut EventContext, ) -> bool

Replace native popover geometry, closing an open fixed-size child first.

Source

pub const fn selection_behavior(&self) -> AutocompleteSelectionBehavior

Source

pub fn set_selection_behavior( &mut self, behavior: AutocompleteSelectionBehavior, ) -> bool

Source

pub fn value(&self) -> &Arc<str> ⓘ

Source

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.

Source

pub fn items(&self) -> &[PickerItem<T>]

Source

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.

Source

pub const fn filter_mode(&self) -> PickerFilterMode

Source

pub fn set_filter_mode( &mut self, filter_mode: PickerFilterMode, cx: &mut EventContext, ) -> bool

Source

pub fn filter(&self) -> Option<&PickerFilter>

The application-supplied filter predicate, when one is installed.

Source

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.

Source

pub const fn popover_window(&self) -> Option<WindowHandle>

Source

pub const fn is_open(&self) -> bool

Source

pub const fn is_disabled(&self) -> bool

Source

pub fn set_disabled(&mut self, disabled: bool, cx: &mut EventContext) -> bool

Source

pub const fn is_invalid(&self) -> bool

Source

pub fn set_invalid(&mut self, invalid: bool) -> bool

Source

pub fn validation_message(&self) -> Option<&Arc<str>>

Source

pub fn set_validation_message(&mut self, message: impl Into<Arc<str>>) -> bool

Source

pub fn clear_validation_message(&mut self) -> bool

Source

pub fn result_count(&self) -> usize

Source

pub fn total_match_count(&self) -> usize

Source

pub fn active_result_index(&self) -> Option<usize>

Source

pub fn active_source_index(&self) -> Option<usize>

Source

pub fn close(&mut self, cx: &mut EventContext) -> bool

Source

pub fn surface_id(id: impl Into<ElementId>) -> ElementId

Source

pub fn option_id_for_source( &self, id: impl Into<ElementId>, source_index: usize, ) -> Option<ElementId>

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T> Debug for AutocompleteState<T>

Source§

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

Formats the value using the given formatter. Read more

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>
where PickerState<T>: Freeze, Option<Entity<AutocompletePopoverSnapshot<T>>>: Freeze,

§

impl<T> Move for AutocompleteState<T>

§

impl<T> Unpin for AutocompleteState<T>
where PickerState<T>: Unpin, Option<Entity<AutocompletePopoverSnapshot<T>>>: Unpin,

§

impl<T> UnsafeUnpin for AutocompleteState<T>
where PickerState<T>: UnsafeUnpin, Option<Entity<AutocompletePopoverSnapshot<T>>>: 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more