Skip to main content
Version: 4.2

CommandPalette

Namespace: Wisej.Web

Assembly: Wisej.Framework (4.2.0.0)

Provides a searchable command popup without occupying space on a page.

public class CommandPalette : Component

The component registers its shortcut while alive; dispose it with the owning page or container. QueryChanged supplies synchronous server results. Selection closes the popup before CommandExecuted. Registered commands and recent history are scoped to this component and this session.

Example:

var palette = new CommandPalette(components);
palette.Commands.Add(new PaletteCommand { Text = "Open orders", Category = "Navigation", Tag = "orders" });
palette.CommandExecuted += (s, e) => NavigateTo((string)e.Command.Tag);
palette.Show();

Constructors​

Instance member CommandPalette()​

Creates a palette with Ctrl+K and local filtering.

Instance member CommandPalette(container)​

Creates a palette owned by a component container.

NameTypeDescription
containerIContainerThe lifetime owner.

Properties​

Instance member CloseAccessibleText​

String: Gets or sets the localized override for the "Close command palette" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member Commands​

CommandCollection: Gets the observable commands available to local filtering and the default server filter.

Instance member CommandsText​

String: Gets or sets the localized override for the "Commands" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member Enabled​

Boolean: Gets or sets whether opening and execution are enabled. Disabling closes an open palette. (Default: True)

Instance member EscapeText​

String: Gets or sets the localized override for the "ESC" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member FilterMode​

CommandFilterMode: Gets or sets whether filtering uses the browser or QueryChanged results on the server. (Default: Client)

Instance member IsOpen​

Boolean: Gets whether the palette is currently open.

Instance member KeyboardHelpText​

String: Gets or sets the localized override for the "↑↓ navigate Enter run Tab category Esc close" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member MaxRecent​

Int32: Gets or sets the maximum retained recent executions, from zero to one hundred. (Default: 5)

Instance member MinimumCharactersText​

String: Gets or sets the localized override for the "Type at least {0} characters" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the minimum character count. Used for the CLDR other category of the current UI culture. Literal braces can be written as {{ and }}.

Instance member MinimumCharacterText​

String: Gets or sets the localized override for the "Type at least {0} character" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation. {0} is the minimum character count. Used for the CLDR one category of the current UI culture. Literal braces can be written as {{ and }}.

Instance member MinQueryLength​

Int32: Gets or sets the minimum trimmed query length, from zero to 1024. Shorter queries display a prompt. (Default: 0)

Instance member NoMatchingCommandsText​

String: Gets or sets the localized override for the "No matching commands" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member PaletteAccessibleText​

String: Gets or sets the localized override for the "Command palette" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member PlaceholderText​

String: Gets or sets the prompt displayed in the empty search field. (Default: null)

Null uses the built-in text for the current UI culture. An empty string suppresses the text.

Instance member RecentText​

String: Gets or sets the localized override for the "Recent" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member SearchAccessibleText​

String: Gets or sets the localized override for the "Search commands" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member SearchingText​

String: Gets or sets the localized override for the "Searching…" text. (Default: null)

The default is null, which selects the built-in translation for the current UI culture. The getter returns the configured override. An empty string suppresses the text without changing the operation.

Instance member Shortcut​

Keys: Gets or sets the global opening shortcut. None unregisters it; Show remains available. (Default: K, Control)

Instance member ShowRecent​

Boolean: Gets or sets whether recent executions appear first for an empty query. (Default: True)

Instance member Width​

Int32: Gets or sets the desired popup width in pixels, from 240 to 1600. The browser viewport caps the actual width. (Default: 560)

Methods​

Protected member Dispose(disposing)​

Releases commands, recent records, and the client popup and shortcut.

ParameterTypeDescription
disposingBooleanWhether managed resources are being released.

Instance member Hide()​

Closes the popup and raises Closed once; hiding an already closed palette has no effect.

Protected member OnClosed(e)​

Raises Closed.

ParameterTypeDescription
eEventArgsEvent data.

Protected member OnCommandExecuted(e)​

Raises CommandExecuted.

ParameterTypeDescription
eCommandEventArgsExecuted command.

Protected member OnOpened(e)​

Raises Opened, including derived overrides without subscribers.

ParameterTypeDescription
eEventArgsEvent data.

Protected member OnQueryChanged(e)​

Raises QueryChanged.

ParameterTypeDescription
eCommandQueryEventArgsQuery and optional results.

Protected member OnWebEvent(e)​

Dispatches browser requests to validated processing methods.

ParameterTypeDescription
eWisejEventArgsClient event data.

Protected member OnWebRender(config)​

Serializes only public command data and wires events independently of subscribers.

ParameterTypeDescription
configObjectThe client component configuration.

Instance member Show()​

Opens the palette with an empty query.

Instance member Show(query)​

Opens or refreshes the palette with a query. Null becomes empty; queries are limited to 1024 characters.

ParameterTypeDescription
queryStringInitial search text.

Calling Show while open replaces the query without raising Opened again. A fresh search epoch invalidates responses and execution requests from earlier openings.

Events​

Instance member Closed​

EventHandler Occurs once when the palette closes, before any execution event.

Instance member CommandExecuted​

EventHandler<CommandEventArgs> Occurs after an enabled result is activated and the popup is closed.

Instance member Opened​

EventHandler Occurs once when a closed palette is shown.

Instance member QueryChanged​

EventHandler<CommandQueryEventArgs> Occurs on Show and accepted query changes. Set Results for server filtering.

Populate Results synchronously. Queries below MinQueryLength do not raise this event. Null Results uses the registered commands; an empty sequence displays no matches.

Example:

palette.FilterMode = CommandFilterMode.Server;
palette.QueryChanged += (s, e) => e.Results = SearchRecords(e.Query);

Implements​

NameDescription
IUserDataProvides access to the UserData and Tag properties associated to the component implementing this interface.
IWisejComponentAll wisej components implement this interface.
IWisejSerializableAllows an object to serialize itself.