pub struct CommandState { /* private fields */ }Expand description
A query input and its fixed collection of searchable actions in one window.
InputState is the query’s source of truth. The characters of each whitespace-separated query term must appear in order, case-insensitively, in the value, label, or keywords. Results rank word-start matches above other substrings and those above looser in-order matches, summed over terms. Groups stay contiguous, ordered by their best result; equal scores and an empty query keep collection order. Query changes highlight the first enabled result. Arrows move that highlight without committing a value, and Enter or a pointer click emits an action.
Keep this entity in the application and observe it to render its results. The command has no open/close lifecycle; compose it inside Dialog when needed.
Implementations§
Source§impl CommandState
impl CommandState
pub fn new( items: impl IntoIterator<Item = SearchItem>, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn input(&self) -> &Entity<InputState>
pub fn input(&self) -> &Entity<InputState>
The native query input, also available for application text styling.
Sourcepub fn focus_handle(&self) -> &FocusHandle
pub fn focus_handle(&self) -> &FocusHandle
The only ordinary Tab stop supplied by this component.
pub fn items(&self) -> &[SearchItem]
Sourcepub fn set_items(
&mut self,
items: impl IntoIterator<Item = SearchItem>,
window: &mut Window,
cx: &mut Context<'_, Self>,
)
pub fn set_items( &mut self, items: impl IntoIterator<Item = SearchItem>, window: &mut Window, cx: &mut Context<'_, Self>, )
Replaces available actions and refilters the existing native query without changing input focus, selection, composition, or editing history. Keeps the highlighted value when it remains enabled and visible.
Sourcepub fn visible_indices(&self) -> &[usize]
pub fn visible_indices(&self) -> &[usize]
Original item indices in display order, including matching disabled items.
Sourcepub fn visible_groups(&self) -> Vec<SharedString>
pub fn visible_groups(&self) -> Vec<SharedString>
Nonempty named groups in first-result order. Render each group’s options
in Self::visible_group_indices order; ungrouped options use None.
pub fn visible_group_indices(&self, group: Option<&str>) -> Vec<usize>
pub fn highlighted_index(&self) -> Option<usize>
Trait Implementations§
impl EventEmitter<CommandEvent> for CommandState
Auto Trait Implementations§
impl !RefUnwindSafe for CommandState
impl !Send for CommandState
impl !Sync for CommandState
impl !UnwindSafe for CommandState
impl Forget for CommandState
impl Freeze for CommandState
impl Move 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
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