pub struct SelectState { /* private fields */ }Expand description
Retained selection, keyboard cursor, disabled state and popup focus.
Applications can replace the ordered options with Self::set_items. Arrow keys wrap and
skip disabled items; opening highlights the committed item or first enabled
item. Enter/Space commits, Escape discards the pending cursor and restores
trigger focus. Home/End highlight an enabled edge while open. Typing searches
labels by a case-insensitive prefix, committing while closed and only moving
the cursor while open. Repeated letters cycle; a one-second pause resets the
prefix. The application owns option presentation, not this behavior.
Implementations§
Source§impl SelectState
impl SelectState
pub fn new( items: impl IntoIterator<Item = SelectItem>, cx: &mut Context<'_, Self>, ) -> Self
pub fn default_value(self, value: impl AsRef<str>) -> Self
pub fn items(&self) -> &[SelectItem]
Sourcepub fn set_items(
&mut self,
items: impl IntoIterator<Item = SelectItem>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_items( &mut self, items: impl IntoIterator<Item = SelectItem>, window: &mut Window, cx: &mut Context<'_, Self>, )
Replaces the options without emitting SelectEvent::Change. A committed
value survives while enabled. An open list keeps its highlighted value,
then prefers the committed value or first enabled option if it disappeared.
With no enabled options the popup closes using its normal focus policy.
pub fn selected_index(&self) -> Option<usize>
pub fn highlighted_index(&self) -> Option<usize>
pub fn selected_item(&self) -> Option<&SelectItem>
Sourcepub fn set_selected_value(
&mut self,
value: Option<&str>,
window: &mut Window,
cx: &mut Context<'_, Self>,
) -> bool
pub fn set_selected_value( &mut self, value: Option<&str>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> bool
Sets or clears the committed value without emitting Change.
Unknown or disabled options are rejected without changing the value, pending cursor, popup or focus. An accepted update closes the popup using its normal focus lifecycle and clears the typeahead prefix. Returns whether the value was accepted, including an unchanged value. Application updates remain available when the control itself is disabled.
pub fn is_open(&self) -> bool
pub fn is_disabled(&self) -> bool
pub fn focus_handle(&self) -> &FocusHandle
pub fn content_focus_handle(&self) -> &FocusHandle
pub fn set_disabled( &mut self, disabled: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
pub fn open(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
pub fn close(&mut self, window: &mut Window, cx: &mut Context<'_, Self>)
Trait Implementations§
impl EventEmitter<SelectEvent> for SelectState
Auto Trait Implementations§
impl !RefUnwindSafe for SelectState
impl !Send for SelectState
impl !Sync for SelectState
impl !UnwindSafe for SelectState
impl Forget for SelectState
impl Freeze for SelectState
impl Move for SelectState
impl Unpin for SelectState
impl UnsafeUnpin for SelectState
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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