pub struct SelectState<D: SearchableListDelegate + 'static>{ /* private fields */ }Expand description
State of the Select component.
Implementations§
Source§impl<D> SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Sourcepub fn new(
delegate: D,
selected_index: Option<IndexPath>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> Self
pub fn new( delegate: D, selected_index: Option<IndexPath>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Create a new Select state.
Sourcepub fn searchable(self, searchable: bool) -> Self
pub fn searchable(self, searchable: bool) -> Self
Sets whether the dropdown menu is searchable, default is false.
When true, a search input appears at the top of the dropdown menu.
Sourcepub fn set_selected_index(
&mut self,
selected_index: Option<IndexPath>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_selected_index( &mut self, selected_index: Option<IndexPath>, window: &mut Window, cx: &mut Context<'_, Self>, )
Set the selected index for the select.
Sourcepub fn set_selected_value(
&mut self,
selected_value: &<D::Item as SearchableListItem>::Value,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_selected_value( &mut self, selected_value: &<D::Item as SearchableListItem>::Value, window: &mut Window, cx: &mut Context<'_, Self>, )
Set selected value for the select.
Looks up the position from the delegate and sets the selected index accordingly.
Passes None when the value is not found.
The delegate looks the value up in its matched items, so an active search query is cleared first to get an index into the full item list.
Sourcepub fn set_items(
&mut self,
items: D,
_: &mut Window,
cx: &mut Context<'_, Self>,
)where
D: SearchableListDelegate + 'static,
pub fn set_items(
&mut self,
items: D,
_: &mut Window,
cx: &mut Context<'_, Self>,
)where
D: SearchableListDelegate + 'static,
Replace the delegate (item data) for the select state.
Sourcepub fn selected_index(&self, cx: &App) -> Option<IndexPath>
pub fn selected_index(&self, cx: &App) -> Option<IndexPath>
Get the current selected index.
Sourcepub fn selected_value(&self) -> Option<&<D::Item as SearchableListItem>::Value>
pub fn selected_value(&self) -> Option<&<D::Item as SearchableListItem>::Value>
Get the current selected value.
Trait Implementations§
impl<D> EventEmitter<DismissEvent> for SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> EventEmitter<SelectEvent<D>> for SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Source§impl<D> Focusable for SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> Focusable for SelectState<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
Returns the focus handle associated with this view.
Source§impl<D> Render for SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
impl<D> Render for SelectState<D>where
D: SearchableListDelegate + 'static,
<D::Item as SearchableListItem>::Value: PartialEq + Clone,
Auto Trait Implementations§
impl<D> !RefUnwindSafe for SelectState<D>
impl<D> !Send for SelectState<D>
impl<D> !Sync for SelectState<D>
impl<D> !UnwindSafe for SelectState<D>
impl<D> Freeze for SelectState<D>where
<<D as SearchableListDelegate>::Item as SearchableListItem>::Value: Sized,
SearchableListState<D>: Freeze,
impl<D> Unpin for SelectState<D>where
<<D as SearchableListDelegate>::Item as SearchableListItem>::Value: Sized,
SearchableListState<D>: Unpin,
impl<D> UnsafeUnpin for SelectState<D>where
<<D as SearchableListDelegate>::Item as SearchableListItem>::Value: Sized,
SearchableListState<D>: 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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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