pub struct CommandPalette { /* private fields */ }Expand description
Material 3 modal command palette built on Dialog and TextField.
Retain an Entity<CommandPaletteState> in your view, mount CommandPalette in the
view tree, and call CommandPaletteState::open or CommandPaletteState::toggle
from a button or Ctrl+K / Cmd+K keybinding.
Implementations§
Source§impl CommandPalette
impl CommandPalette
Sourcepub fn new(
id: impl Into<ElementId>,
state: &Entity<CommandPaletteState>,
items: impl IntoIterator<Item = CommandItem>,
) -> CommandPalette
pub fn new( id: impl Into<ElementId>, state: &Entity<CommandPaletteState>, items: impl IntoIterator<Item = CommandItem>, ) -> CommandPalette
Creates a modal command palette bound to state with the supplied ordered items.
Sourcepub fn grouped(
id: impl Into<ElementId>,
state: &Entity<CommandPaletteState>,
groups: impl IntoIterator<Item = CommandGroup>,
) -> CommandPalette
pub fn grouped( id: impl Into<ElementId>, state: &Entity<CommandPaletteState>, groups: impl IntoIterator<Item = CommandGroup>, ) -> CommandPalette
Creates a modal command palette from grouped CommandGroup collections.
Sourcepub fn accessible_label(self, label: impl Into<SharedString>) -> CommandPalette
pub fn accessible_label(self, label: impl Into<SharedString>) -> CommandPalette
Overrides the accessible dialog name (defaults to "Command palette").
Sourcepub fn placeholder(self, placeholder: impl Into<SharedString>) -> CommandPalette
pub fn placeholder(self, placeholder: impl Into<SharedString>) -> CommandPalette
Overrides the search field placeholder (defaults to
gpui_material_theme::MaterialStrings::search_prompt).
Sourcepub fn empty_label(self, label: impl Into<SharedString>) -> CommandPalette
pub fn empty_label(self, label: impl Into<SharedString>) -> CommandPalette
Overrides the empty-results message (defaults to
gpui_material_theme::MaterialStrings::no_results).
Sourcepub fn close_label(self, label: impl Into<SharedString>) -> CommandPalette
pub fn close_label(self, label: impl Into<SharedString>) -> CommandPalette
Overrides the close button’s accessible label (defaults to
gpui_material_theme::MaterialStrings::close).
Sourcepub fn filter(
self,
predicate: impl Fn(&CommandItem, &str) -> bool + 'static,
) -> CommandPalette
pub fn filter( self, predicate: impl Fn(&CommandItem, &str) -> bool + 'static, ) -> CommandPalette
Supplies a custom filtering predicate (item, query) -> bool replacing the built-in
case-insensitive multi-token substring and keyword matcher.
Sourcepub fn close_on_select(self, close: bool) -> CommandPalette
pub fn close_on_select(self, close: bool) -> CommandPalette
Sets whether executing a command automatically closes the palette (defaults to true).
Sourcepub fn width(self, width: Pixels) -> CommandPalette
pub fn width(self, width: Pixels) -> CommandPalette
Sets the maximum width of the command palette surface in logical pixels (defaults to 580px).
Sourcepub fn max_results_height(self, height: Pixels) -> CommandPalette
pub fn max_results_height(self, height: Pixels) -> CommandPalette
Sets the maximum scrollable height of the results region in logical pixels (defaults to 360px).
Sourcepub fn layer(self, layer: usize) -> CommandPalette
pub fn layer(self, layer: usize) -> CommandPalette
Sets the modal z-layer forwarded to the underlying Dialog.
Sourcepub fn properties(self, properties: DialogProperties) -> CommandPalette
pub fn properties(self, properties: DialogProperties) -> CommandPalette
Configures Escape and outside-click dismissal behavior.
Sourcepub fn shape(self, shape: CornerShape) -> CommandPalette
pub fn shape(self, shape: CornerShape) -> CommandPalette
Overrides the corner shape of the command palette surface (defaults to CornerRole::ExtraLarge).
Sourcepub fn colors(self, colors: CommandPaletteColors) -> CommandPalette
pub fn colors(self, colors: CommandPaletteColors) -> CommandPalette
Overrides container, divider, heading, active row, shortcut badge, and scrim colors.
Sourcepub fn scrim_opacity(self, opacity: f32) -> CommandPalette
pub fn scrim_opacity(self, opacity: f32) -> CommandPalette
Sets backdrop scrim opacity clamped to 0.0..=1.0 (defaults to 0.32).
Renders optional footer content beneath the results list (for example keyboard hints).
Sourcepub fn on_select(
self,
handler: impl Fn(&CommandItem, &mut Window, &mut App) + 'static,
) -> CommandPalette
pub fn on_select( self, handler: impl Fn(&CommandItem, &mut Window, &mut App) + 'static, ) -> CommandPalette
Invoked when an enabled command is executed via Enter or pointer click.
Sourcepub fn on_dismiss_request(
self,
handler: impl Fn(DialogCloseReason, &mut Window, &mut App) -> bool + 'static,
) -> CommandPalette
pub fn on_dismiss_request( self, handler: impl Fn(DialogCloseReason, &mut Window, &mut App) -> bool + 'static, ) -> CommandPalette
Handles Escape and outside-click dismissal requests. Return false to keep the palette open.
Sourcepub fn on_closed(
self,
handler: impl Fn(DialogCloseReason, &mut Window, &mut App) + 'static,
) -> CommandPalette
pub fn on_closed( self, handler: impl Fn(DialogCloseReason, &mut Window, &mut App) + 'static, ) -> CommandPalette
Invoked once when the palette closes due to user dismissal or selection.
Trait Implementations§
Source§impl IntoElement for CommandPalette
impl IntoElement for CommandPalette
Source§type Element = ViewElement<CommandPalette>
type Element = ViewElement<CommandPalette>
Source§fn into_element(self) -> <CommandPalette as IntoElement>::Element
fn into_element(self) -> <CommandPalette as IntoElement>::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for CommandPalette
impl RenderOnce for CommandPalette
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for CommandPalette
impl !Send for CommandPalette
impl !Sync for CommandPalette
impl !UnwindSafe for CommandPalette
impl Forget for CommandPalette
impl Freeze for CommandPalettewhere
NonZero<u32>: Freeze,
&'static str: Freeze,
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const ArcInner<Path> is !null: Freeze,
PhantomData<ArcInner<Path>>: Freeze,
*const str is !null: Freeze,
PhantomData<&'static str>: Freeze,
*const ArcInner<ElementId> is !null: Freeze,
PhantomData<ArcInner<ElementId>>: Freeze,
*const (): Freeze,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Freeze,
PhantomData<fn(CommandPaletteState) -> CommandPaletteState>: Freeze,
*const u8 is !null: Freeze,
PhantomData<CommandItem>: Freeze,
*const RcInner<dyn Fn(&CommandItem, &str) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&CommandItem, &str) -> bool>>: Freeze,
*mut dyn ElementObject: Freeze,
*const RcInner<Cell<bool>> is !null: Freeze,
PhantomData<RcInner<Cell<bool>>>: Freeze,
*const RcInner<dyn Fn(&CommandItem, &mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(&CommandItem, &mut Window, &mut App)>>: Freeze,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool> is !null: Freeze,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool>>: Freeze,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)> is !null: Freeze,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)>>: Freeze,
impl Move for CommandPalette
impl Unpin for CommandPalettewhere
NonZero<u32>: Unpin,
&'static str: Unpin,
Arc<str>: Unpin,
Arc<Path>: Unpin,
*const str is !null: Unpin,
Arc<ElementId>: Unpin,
*const (): Unpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: Unpin,
*const u8 is !null: Unpin,
Rc<dyn Fn(&CommandItem, &str) -> bool>: Unpin,
*mut dyn ElementObject: Unpin,
Rc<Cell<bool>>: Unpin,
Rc<dyn Fn(&CommandItem, &mut Window, &mut App)>: Unpin,
Rc<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool>: Unpin,
Rc<dyn Fn(DialogCloseReason, &mut Window, &mut App)>: Unpin,
impl UnsafeUnpin for CommandPalettewhere
NonZeroU32Inner: UnsafeUnpin,
&'static str: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const ArcInner<Path> is !null: UnsafeUnpin,
PhantomData<ArcInner<Path>>: UnsafeUnpin,
*const str is !null: UnsafeUnpin,
PhantomData<&'static str>: UnsafeUnpin,
*const ArcInner<ElementId> is !null: UnsafeUnpin,
PhantomData<ArcInner<ElementId>>: UnsafeUnpin,
*const (): UnsafeUnpin,
*const ArcInner<RwLock<RawRwLock, EntityRefCounts>> is !null: UnsafeUnpin,
PhantomData<fn(CommandPaletteState) -> CommandPaletteState>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<CommandItem>: UnsafeUnpin,
*const RcInner<dyn Fn(&CommandItem, &str) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&CommandItem, &str) -> bool>>: UnsafeUnpin,
*mut dyn ElementObject: UnsafeUnpin,
*const RcInner<Cell<bool>> is !null: UnsafeUnpin,
PhantomData<RcInner<Cell<bool>>>: UnsafeUnpin,
*const RcInner<dyn Fn(&CommandItem, &mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(&CommandItem, &mut Window, &mut App)>>: UnsafeUnpin,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App) -> bool>>: UnsafeUnpin,
*const RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)> is !null: UnsafeUnpin,
PhantomData<RcInner<dyn Fn(DialogCloseReason, &mut Window, &mut App)>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
fn test_text(self, text: impl Into<SharedString>) -> ObservedText<Self::Element>
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(
self,
text: impl Into<SharedString>,
) -> ObservedText<Self::Element>
fn test_alt_text( self, text: impl Into<SharedString>, ) -> ObservedText<Self::Element>
Self::test_text for an image’s alternative text, which
stands in for what the element draws.