pub struct ComboboxState<D: SearchableListDelegate + 'static>{ /* private fields */ }Expand description
State of the Combobox component.
Implementations§
Source§impl<D> ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Sourcepub fn new(
delegate: D,
selected_indices: Vec<IndexPath>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( delegate: D, selected_indices: Vec<IndexPath>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Create a new Combobox state.
Sourcepub fn multiple(self, multiple: bool) -> Self
pub fn multiple(self, multiple: bool) -> Self
Enable multi-select mode.
When true, clicking an item toggles it in the selection and the popover stays open.
When false (default), clicking an item replaces the selection and closes the popover.
Sourcepub fn searchable(self, searchable: bool) -> Self
pub fn searchable(self, searchable: bool) -> Self
Enable or disable the search input at the top of the dropdown.
Sourcepub fn selected_values(&self) -> Vec<<D::Item as SearchableListItem>::Value>
pub fn selected_values(&self) -> Vec<<D::Item as SearchableListItem>::Value>
Return the currently selected values.
Sourcepub fn selected_value(&self) -> Option<<D::Item as SearchableListItem>::Value>
pub fn selected_value(&self) -> Option<<D::Item as SearchableListItem>::Value>
Return the first selected value, or None when nothing is selected.
Convenience for single-select mode (.multiple(false)).
Sourcepub fn selection(&self) -> &[(IndexPath, D::Item)]
pub fn selection(&self) -> &[(IndexPath, D::Item)]
Return the currently selected (IndexPath, Item) pairs.
Sourcepub fn set_selected_values(
&mut self,
values: &[<D::Item as SearchableListItem>::Value],
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_selected_values( &mut self, values: &[<D::Item as SearchableListItem>::Value], window: &mut Window, cx: &mut Context<'_, Self>, )
Replace the entire selection set by item values.
Values are resolved through the current delegate. Values that cannot be resolved are
ignored. This updates the committed selection and snapshot without emitting a
ComboboxEvent.
Sourcepub fn set_selected_indices(
&mut self,
indices: impl IntoIterator<Item = IndexPath>,
_window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_selected_indices( &mut self, indices: impl IntoIterator<Item = IndexPath>, _window: &mut Window, cx: &mut Context<'_, Self>, )
Replace the entire selection set.
Sourcepub fn add_selected_index(
&mut self,
index: IndexPath,
cx: &mut Context<'_, Self>,
) -> bool
pub fn add_selected_index( &mut self, index: IndexPath, cx: &mut Context<'_, Self>, ) -> bool
Add a single index to the selection, if not already present, returning whether it was added.
Sourcepub fn remove_selected_index(
&mut self,
index: IndexPath,
cx: &mut Context<'_, Self>,
) -> bool
pub fn remove_selected_index( &mut self, index: IndexPath, cx: &mut Context<'_, Self>, ) -> bool
Remove a single index from the selection, returning whether it was removed.
Sourcepub fn clear_selection(&mut self, cx: &mut Context<'_, Self>)
pub fn clear_selection(&mut self, cx: &mut Context<'_, Self>)
Clear all selected values.
Sourcepub fn set_items(
&mut self,
items: D,
_: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_items( &mut self, items: D, _: &mut Window, cx: &mut Context<'_, Self>, )
Replace the underlying delegate (item data source).
Sourcepub fn query(&self, cx: &App) -> SharedString
pub fn query(&self, cx: &App) -> SharedString
Returns the search query.
Trait Implementations§
impl<D> EventEmitter<ComboboxEvent<D>> for ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> EventEmitter<DismissEvent> for ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Source§impl<D> Focusable for ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> Focusable for ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Source§fn focus_handle(&self, cx: &App) -> FocusHandle
fn focus_handle(&self, cx: &App) -> FocusHandle
Source§impl<D> Render for ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> Render for ComboboxState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Auto Trait Implementations§
impl<D> !RefUnwindSafe for ComboboxState<D>
impl<D> !Send for ComboboxState<D>
impl<D> !Sync for ComboboxState<D>
impl<D> !UnwindSafe for ComboboxState<D>
impl<D> Freeze for ComboboxState<D>where
<<D as SearchableListDelegate>::Item as SearchableListItem>::Value: Sized,
SearchableListState<D>: Freeze,
Option<Box<dyn Fn(&ComboboxTriggerContext<'_, D>, &mut Window, &mut App) -> AnyElement>>: Freeze,
impl<D> Unpin for ComboboxState<D>where
<<D as SearchableListDelegate>::Item as SearchableListItem>::Value: Sized,
SearchableListState<D>: Unpin,
Option<Box<dyn Fn(&ComboboxTriggerContext<'_, D>, &mut Window, &mut App) -> AnyElement>>: Unpin,
impl<D> UnsafeUnpin for ComboboxState<D>where
<<D as SearchableListDelegate>::Item as SearchableListItem>::Value: Sized,
SearchableListState<D>: UnsafeUnpin,
Option<Box<dyn Fn(&ComboboxTriggerContext<'_, D>, &mut Window, &mut App) -> AnyElement>>: UnsafeUnpin,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more