Vixen
02b45cc4
csharp
public sealed class CommandPalette

Fuzzy search over everything the editor can do, reached with one chord.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Cheap to build on the registry, and the feature power users judge tooling by — doc 11's words, and the reason it is in the first version of the shell rather than a later one. Nothing here knows what a command is beyond IPaletteSource: commands, assets, scene objects and settings all arrive the same way.

⚠ The field keeps the focus and the rows never take it. A palette where Down moved the focus into the list is one where the next letter typed goes nowhere — so the arrows move a highlight this class owns, and the rows are not focusable at all. It is the opposite arrangement to Menu, whose items are the focus, and for the opposite reason: a menu has no text field to protect.

⚠ Rows are rebuilt per query and capped. Ten results is what fits and what anybody reads; a palette that realised a thousand rows to show ten would be the tree view's virtualisation problem without the tree view's payoff.

Fields and properties (11)

  • protected override string TagName

    The element name this type answers to when a caller does not choose one.

  • public int Limit

    How many results are shown.

  • public bool GroupBySource

    Whether the best results are kept together by the source they came from.

  • public bool RequiresQuery

    Whether an empty query shows nothing rather than asking the sources.

  • public SearchBox Field

    What is typed into it.

  • public UiElement List

    Where the rows go.

  • public UiElement EmptyPart

    What it says when nothing matched.

  • public UiElement PreviewPart

    The pane under the rows describing whatever is highlighted.

  • public IReadOnlyList<IPaletteSource> Sources

    Where it looks, in order.

  • public IReadOnlyList<PaletteItem> Results

    What it is currently showing, best first.

  • public int Highlighted

    Which result is highlighted, or -1.

Methods (7)

  • protected override void OnCreated()

    Builds whatever this element is made of, once, as it joins a document.

  • public void AddSource(IPaletteSource source)

    Adds somewhere for it to look.

  • public void OpenPalette()

    Opens it in the middle of the top of the document, empty.

  • public bool Accept()

    Runs the highlighted result and closes.

  • public void Move(int delta)

    Moves the highlight.

  • public void Refresh()

    Asks every source what matches what is typed, and shows the best of it.

  • protected override void OnOpened()

    Called after it opens.

Used by (6)

  • EditorApplicationVixen.Editor.App
  • EditorChromeVisualTestsVixen.Editor.Ui.Tests
  • EditorShellVixen.Editor.Ui
  • EditorShellTestsVixen.Editor.Ui.Tests
  • MilestoneE3TestsVixen.Editor.App.Tests
  • PaletteTestsVixen.Editor.Ui.Tests