CommandPalette コンポーネント — sgcHTML | eSeGeCe

CommandPalette

TsgcHTMLComponent_CommandPalette — Delphi、C++ Builder、.NET で、VS Code、Slack、Linear でおなじみの Ctrl+K / Cmd+K オーバーレイランチャーをレンダリングします。部分一致からあいまい検索へと進むフィルタリング、カテゴリー分け、サーバーへルーティングされるアクションを備えています。

TsgcHTMLComponent_CommandPalette

AddItem または Items.Add でエントリを追加してから、HTML プロパティを読み取ります。Ctrl+K(または Cmd+K)でオーバーレイが開き、入力すると絞り込まれ、Enter で選択項目が実行されます。

コンポーネントクラス

TsgcHTMLComponent_CommandPalette

レンダリング内容

非表示の Ctrl+K オーバーレイ + インラインスクリプト

言語

Delphi, C++ Builder, .NET

エントリを追加して Ctrl+K を押す

エントリはクライアント側でフィルタリングするための JSON としてブラウザーへ送られるのではなく、サーバー側でマークアップとしてレンダリングされます。そのため、各キャプションは必ず一度だけ HTML エンコードされます。

uses
  sgcHTML_Component_CommandPalette;

var
  oPalette: TsgcHTMLComponent_CommandPalette;
begin
  oPalette := TsgcHTMLComponent_CommandPalette.Create(nil);
  try
    oPalette.PaletteID := 'app_commands';

    oPalette.AddItem('New Invoice', '/invoices/new', 'invoice:new', 'Create', 'Ctrl+N');
    oPalette.AddItem('Customer Search', '/customers', '', 'Navigate');
    with oPalette.Items.Add do
    begin
      Caption := 'Export Report';
      Icon := 'bi bi-download';
      DataAction := 'report:export';
      Category := 'Actions';
    end;

    WebModule.Response := oPalette.HTML;   // hidden overlay + inline script
  finally
    oPalette.Free;
  end;
end;
// includes: sgcHTML_Component_CommandPalette.hpp

TsgcHTMLComponent_CommandPalette *oPalette = new TsgcHTMLComponent_CommandPalette(NULL);
try
{
  oPalette->PaletteID = "app_commands";

  oPalette->AddItem("New Invoice", "/invoices/new", "invoice:new", "Create", "Ctrl+N");

  TsgcHTMLCommandItem *oItem = oPalette->Items->Add();
  oItem->Caption = "Export Report";
  oItem->Icon = "bi bi-download";
  oItem->DataAction = "report:export";
  oItem->Category = "Actions";

  String html = oPalette->HTML;   // hidden overlay + inline script
}
__finally
{
  delete oPalette;
}
using esegece.sgcWebSockets;

var palette = new TsgcHTMLComponent_CommandPalette();
palette.PaletteID = "app_commands";

palette.AddItem("New Invoice", "/invoices/new", "invoice:new", "Create", "Ctrl+N");

var item = palette.Items.Add();
item.Caption = "Export Report";
item.Icon = "bi bi-download";
item.DataAction = "report:export";
item.Category = "Actions";

string html = palette.HTML;   // hidden overlay + inline script

主なプロパティとメソッド

最もよく使うメンバーです。

Items

TsgcHTMLCommandItem エントリのコレクションです。CaptionDescriptionIconHrefDataActionShortcut(表示のみ)、CategoryEnabled を持ちます。

AddItem

1 件のエントリを追加してそれを返す便利メソッドです。後から IconDescription を設定することもできます。

HotKey / HotKeyCtrl / HotKeyMeta

1 文字とモディファイアキーの組み合わせです。CtrlMeta はどちらも既定値が True のため、Ctrl+K と Cmd+K の両方がそのまま利用できます。

MaxResults

既定値は 10 です。0 にすると、一致するすべてのエントリを一度に表示します。

ShowCategories

既定値は True で、リストを見出しごとにグループ化します。順序はアルファベット順ではなく、最初に現れた順です。

WSSend / Action

コマンドを実行すると sgc:command の DOM イベントが常に発火し、いずれかを設定していれば sgcHTMX の WebSocket ブリッジ経由でプッシュするか Action に POST します。

さらに詳しく

オンラインヘルプこのコンポーネントの完全な API リファレンスと使用ガイドです。
すべての sgcHTML コンポーネント80 以上のコンポーネントの全機能マトリックスを閲覧できます。
無料体験版のダウンロード30 日間の体験版には 60.HTML デモプロジェクトが付属します。
価格完全なソースコード付きの Single、Team、Site ライセンス。
最もお得な選択: All-AccesseSeGeCe の全製品にプレミアムサポートが付いて、年間 €1,059 からご利用いただけます。
All-Access の価格を見る

始める準備はできましたか?

無料体験版をダウンロードして、Delphi、C++ Builder、.NET で Web UI の構築を始めましょう。