Vixen
feb85697
csharp
public sealed class KeyBindingsView

Every command, its chord, and where the chord came from — and the place to change one.

Read the guide page for this →

Remarks

The panel is KeyBindingsView.vxml; this file is the accessibility modifier and the record the grid's rows are made of. The emitter's partial carries no modifier, so the declaration that says public has to be here.

⚠ A control library's since #650, and before that the editor's. Doc 20's A5 asked for it as an editor panel, and nothing in it was ever the editor's business: a KeyMap and a CommandRegistry are Vixen.Ui.Controls types, so an application that could dispatch a chord and draw one beside a menu item could not show a list of them or let anybody change one. The editor now hosts this panel as any application would, supplying its preset names through PresetNames and its keymap file through the two events below.

⚠ The preset dropdown is the point and the grid is the consolation. Doc 20's own note is that "presets matter more than they look" — a Unity user and an Unreal user disagree about most of the bar and both are certain — so the one control that turns a week of friction into a choice is the preset picker, and it is first on the strip for that reason.

⚠ Capture is a mode with a visible end, not a modal. While it is on, every key the panel sees is a candidate binding — including Escape, which is what cancels it, and which is therefore the one chord this panel will not let you bind. The alternative is a dialog, and a dialog that swallows keystrokes to record them cannot be driven by the automation harness or screenshotted, which is DialogService's own argument turned round.

⚠ Import and export are events rather than file calls. A control has no file picker and is deliberately not given one, so the panel says what the user asked for and the application, which has the picker, answers — reading the file with KeyMapYaml or with whatever format it keeps its preferences in.

Fields and properties (16)

  • protected override string TagName
  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • protected override AccessibleRole NativeRole
  • public UiElement Toolbar

    The strip along the top.

  • public SearchBox Search

    The filter box.

  • public Select Presets

    Which keymap preset is in force.

  • public IReadOnlyList<string> PresetNames

    The presets the picker offers, by name, in the order it offers them.

  • public Button Record

    The button that puts the panel into capture mode.

  • public Button Import

    The button that asks for a keymap file to be read in.

  • public Button Export
  • public DataGrid Grid

    The grid.

  • public UiElement Status

    The line under it that reports a conflict, or says what capture is waiting for.

  • public bool IsCapturing

    Whether the next chord pressed is a binding rather than a shortcut.

  • public string? Selected

    Which command the grid has selected, or .

  • public string? Conflict

    Which command holds the chord the user just tried to take, if the bind was refused.

  • public KeyChord Pending

    The chord that was refused, so pressing it again can mean "take it".

Events (2)

  • public Action<KeyBindingsView>? ImportRequested

    Raised when the user asks to read a keymap in from a file.

  • public Action<KeyBindingsView>? ExportRequested

    Raised when they ask to write one out.

Methods (7)

  • protected override void OnCreated()
  • protected override void OnRemoved()
  • public void Show(CommandRegistry registry, KeyMap map)

    Points the panel at a registry and the map that binds it.

  • public void Rebuild()

    Rebuilds the row list from the registry, honouring the filter.

  • public void Refresh()

    Reads every cell again without rebuilding the list.

  • public void Capture(bool on)

    Turns capture mode on or off.

  • public BindResult Rebind(KeyChord chord, bool replace = false)

    Gives the selected command a chord.

Used by (8)

  • KeyBindingsViewTestsVixen.Ui.Controls.Advanced.Tests
  • EditorApplicationVixen.Editor.App
  • EditorShellVixen.Editor.Ui
  • HarnessVixen.Editor.Ui.Tests
  • KeyBindingsPanelTestsVixen.Editor.App.Tests
  • KeyBindingsViewDumpTestsVixen.Editor.Ui.Tests
  • MilestoneE3TestsVixen.Editor.App.Tests
  • SelfHandlerKeyTestsVixen.Editor.Ui.Tests