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 new(
window: &mut Window,
cx: &mut Context<'_, CommandState>,
) -> CommandState
pub fn new( window: &mut Window, cx: &mut Context<'_, CommandState>, ) -> CommandState
Create an empty palette.
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<'_, CommandState>,
)
pub fn set_query( &mut self, query: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, CommandState>, )
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<'_, CommandState>,
)
pub fn set_selected_index( &mut self, index: Option<IndexPath>, window: &mut Window, cx: &mut Context<'_, CommandState>, )
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<'_, CommandState>,
)
pub fn set_loading( &mut self, loading: bool, window: &mut Window, cx: &mut Context<'_, CommandState>, )
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
Source§fn render(
&mut self,
window: &mut Window,
cx: &mut Context<'_, CommandState>,
) -> impl IntoElement
fn render( &mut self, window: &mut Window, cx: &mut Context<'_, CommandState>, ) -> impl IntoElement
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> 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