pub struct CommandState { /* private fields */ }Expand description
The interaction state of a crate::command::Command palette: its query,
focus, scrolling, and highlighted command.
Implementations§
Source§impl CommandState
impl CommandState
Sourcepub fn query(&self, cx: &App) -> SharedString
pub fn query(&self, cx: &App) -> SharedString
The current search query.
Sourcepub fn set_query(
&mut self,
query: impl Into<SharedString>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_query( &mut self, query: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, Self>, )
Replace the search query, as if it had been typed.
The input suppresses its own change event for a programmatic write, so the re-filter and query callback happen here instead.
Sourcepub fn selected_index(&self) -> Option<IndexPath>
pub fn selected_index(&self) -> Option<IndexPath>
The highlighted item’s path in the model installed by the latest
crate::command::Command render, before local filtering.
Ungrouped items occupy section 0 and use their input position as the row. Explicit groups use their group and item positions; when a model mixes both forms, the implicit ungrouped section comes first.
Sourcepub fn set_selected_index(
&mut self,
index: Option<IndexPath>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_selected_index( &mut self, index: Option<IndexPath>, window: &mut Window, cx: &mut Context<'_, Self>, )
Highlight an item by its original, unfiltered model path, or clear the
highlight with None.
A path that is currently filtered out or disabled clears the highlight. A visible selection is scrolled into view.
Sourcepub fn matched_count(&self) -> usize
pub fn matched_count(&self) -> usize
The number of items matching the current query.
Sourcepub fn focus(&self, window: &mut Window, cx: &mut App)
pub fn focus(&self, window: &mut Window, cx: &mut App)
Move focus to the palette’s active control.
Sourcepub fn set_loading(
&mut self,
loading: bool,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_loading( &mut self, loading: bool, window: &mut Window, cx: &mut Context<'_, Self>, )
Show or hide the search field’s spinner, and suppress the empty message while it spins.
Turn it on while an on_query callback is being answered.
Sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Whether the search field is showing its spinner.
Trait Implementations§
Source§impl Focusable for CommandState
impl Focusable for CommandState
Source§fn focus_handle(&self, cx: &App) -> FocusHandle
fn focus_handle(&self, cx: &App) -> FocusHandle
Source§impl Render for CommandState
impl Render for CommandState
Auto Trait Implementations§
impl !RefUnwindSafe for CommandState
impl !Send for CommandState
impl !Sync for CommandState
impl !UnwindSafe for CommandState
impl Freeze for CommandState
impl Unpin for CommandState
impl UnsafeUnpin for CommandState
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