pub struct CommandPaletteState { /* private fields */ }Expand description
Retains modal visibility, search editor, scroll position, and active selection state
for a super::CommandPalette.
Implementations§
Source§impl CommandPaletteState
impl CommandPaletteState
Sourcepub fn new(
window: &mut Window,
cx: &mut Context<'_, CommandPaletteState>,
) -> CommandPaletteState
pub fn new( window: &mut Window, cx: &mut Context<'_, CommandPaletteState>, ) -> CommandPaletteState
Creates a closed command palette state with an owned TextFieldState and DialogState.
Sourcepub fn with_editor(
input: &Entity<InputBaseState<InputMode>>,
window: &mut Window,
cx: &mut Context<'_, CommandPaletteState>,
) -> CommandPaletteState
pub fn with_editor( input: &Entity<InputBaseState<InputMode>>, window: &mut Window, cx: &mut Context<'_, CommandPaletteState>, ) -> CommandPaletteState
Creates a closed command palette state reusing a caller-owned TextFieldState.
Sourcepub fn clear_on_open(self, clear: bool) -> CommandPaletteState
pub fn clear_on_open(self, clear: bool) -> CommandPaletteState
Configures whether Self::open clears the previous query text (defaults to true).
Sourcepub fn query(&self) -> &SharedString
pub fn query(&self) -> &SharedString
Returns the latest committed query text.
Sourcepub fn active_command_id(&self) -> Option<&SharedString>
pub fn active_command_id(&self) -> Option<&SharedString>
Returns the currently highlighted command ID, if explicitly selected.
Sourcepub fn dialog_state(&self) -> &Entity<DialogState>
pub fn dialog_state(&self) -> &Entity<DialogState>
Returns the underlying DialogState entity.
Sourcepub fn editor(&self) -> &Entity<InputBaseState<InputMode>>
pub fn editor(&self) -> &Entity<InputBaseState<InputMode>>
Returns the retained TextFieldState backing the search input.
Sourcepub fn input_focus(&self, cx: &App) -> FocusHandle
pub fn input_focus(&self, cx: &App) -> FocusHandle
Returns the focus handle of the search input editor.
Sourcepub fn scroll_handle(&self) -> &ScrollHandle
pub fn scroll_handle(&self) -> &ScrollHandle
Returns the retained scroll handle bound to the results list.
Sourcepub fn open(
&mut self,
window: &mut Window,
cx: &mut Context<'_, CommandPaletteState>,
)
pub fn open( &mut self, window: &mut Window, cx: &mut Context<'_, CommandPaletteState>, )
Opens the command palette, capturing current focus for restoration and focusing the search input.
Sourcepub fn close(
&mut self,
window: &mut Window,
cx: &mut Context<'_, CommandPaletteState>,
)
pub fn close( &mut self, window: &mut Window, cx: &mut Context<'_, CommandPaletteState>, )
Closes the command palette programmatically and restores prior focus.
Sourcepub fn toggle(
&mut self,
window: &mut Window,
cx: &mut Context<'_, CommandPaletteState>,
)
pub fn toggle( &mut self, window: &mut Window, cx: &mut Context<'_, CommandPaletteState>, )
Toggles the command palette open or closed (convenient for Ctrl+K / Cmd+K bindings).
Sourcepub fn set_query(
&mut self,
query: impl Into<SharedString>,
window: &mut Window,
cx: &mut Context<'_, CommandPaletteState>,
)
pub fn set_query( &mut self, query: impl Into<SharedString>, window: &mut Window, cx: &mut Context<'_, CommandPaletteState>, )
Updates the query text programmatically and resets the active command highlight.
Sourcepub fn set_active_command(
&mut self,
id: Option<SharedString>,
cx: &mut Context<'_, CommandPaletteState>,
)
pub fn set_active_command( &mut self, id: Option<SharedString>, cx: &mut Context<'_, CommandPaletteState>, )
Explicitly highlights a command ID within the filtered list.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CommandPaletteState
impl !Send for CommandPaletteState
impl !Sync for CommandPaletteState
impl !UnwindSafe for CommandPaletteState
impl Forget for CommandPaletteState
impl Freeze for CommandPaletteStatewhere
NonZero<u32>: Freeze,
*const (): Freeze,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Freeze,
PhantomData<fn(DialogState) -> DialogState>: Freeze,
PhantomData<fn(InputBaseState<InputMode>) -> InputBaseState<InputMode>>: Freeze,
*const RcInner<RefCell<ScrollHandleState>> is !null: Freeze,
PhantomData<RcInner<RefCell<ScrollHandleState>>>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const dyn FnOnce() is !null: Freeze,
PhantomData<dyn FnOnce()>: Freeze,
impl Move for CommandPaletteState
impl Unpin for CommandPaletteState
impl UnsafeUnpin for CommandPaletteStatewhere
NonZeroU32Inner: UnsafeUnpin,
*const (): UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: UnsafeUnpin,
PhantomData<fn(DialogState) -> DialogState>: UnsafeUnpin,
PhantomData<fn(InputBaseState<InputMode>) -> InputBaseState<InputMode>>: UnsafeUnpin,
*const RcInner<RefCell<ScrollHandleState>> is !null: UnsafeUnpin,
PhantomData<RcInner<RefCell<ScrollHandleState>>>: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const dyn FnOnce() is !null: UnsafeUnpin,
PhantomData<dyn FnOnce()>: 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
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