Vixen
02b45cc4
csharp
public abstract class ButtonBase

Anything that can be pressed.

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

Remarks

A button, a menu item, a tab, a page number, a link. They look nothing alike and they all answer to the same four things — a tap, Space, Enter, and code — so the four live here once rather than in nine controls that would each get one of them slightly wrong.

⚠ Space activates on release and Enter on press, which is not an inconsistency. It is what every desktop toolkit and every browser does, and the reason is that Space is the key you can back out of: holding it shows the button pressed, and moving the focus away before letting go cancels. Enter has no such affordance because Enter is the one that submits, and a form that waited for the release would feel late. Swapping either makes the control feel wrong in a way users report as "sticky" without being able to say why.

The label is a child element rather than text on the control, and that is forced: an element with text measures itself and may not have children, so a button that carried its own label could never also have an icon, and its text could not be centred inside a button that had been stretched. One element buys both.

Fields and properties (5)

  • public string? Label

    What it says.

  • public Icon LeadingIcon

    An icon before the label, created the first time it is asked for.

  • public bool HasIcon

    Whether it has been given an icon, without giving it one.

  • protected UiElement LabelPart

    The element the label is drawn on, for a control that wants to restyle or replace it.

  • protected virtual bool ActivatesOnEnter

    Whether Enter activates it as well as Space.

Methods (3)

  • protected override void OnCreated()

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

  • public void Activate()

    Activates it as though it had been clicked.

  • protected virtual void Activate(ActivationDevice device, int count, ModifierKeys modifiers)

    What activation means for this control.

Used by (124, showing 40)

  • ShellHelloUi
  • DocumentBenchmarksVixen.Benchmarks.Ui
  • BreadcrumbVixen.Ui.Controls
  • BreadcrumbItemVixen.Ui.Controls
  • ButtonVixen.Ui.Controls
  • ButtonTestsVixen.Ui.Controls.Tests
  • CheckBoxVixen.Ui.Controls
  • ColorPickerVixen.Ui.Controls.Advanced
  • ComboBoxVixen.Ui.Controls
  • ControlVisualTestsVixen.Ui.Controls.Tests
  • DialogVixen.Ui.Controls
  • DisabledStateTestsVixen.Ui.Controls.Tests
  • DockGroupViewVixen.Ui.Controls.Advanced
  • DockTabVixen.Ui.Controls.Advanced
  • DockingHostVixen.Ui.Controls.Advanced
  • DockingTestsVixen.Ui.Controls.Advanced.Tests
  • ExpanderVixen.Ui.Controls
  • ExpanderHeaderVixen.Ui.Controls
  • IconButtonVixen.Ui.Controls
  • LinkVixen.Ui.Controls
  • MenuVixen.Ui.Controls
  • MenuBarVixen.Ui.Controls
  • MenuBarItemVixen.Ui.Controls
  • MenuItemVixen.Ui.Controls
  • MultiSelectVixen.Ui.Controls
  • OptionVixen.Ui.Controls
  • PageButtonVixen.Ui.Controls
  • PaginationVixen.Ui.Controls
  • PressableVixen.Ui.Controls.Tests
  • PropertyRowVixen.Ui.Controls.Advanced
  • RadialItemVixen.Ui.Controls
  • RadialMenuVixen.Ui.Controls
  • RadioButtonVixen.Ui.Controls
  • RadioGroupVixen.Ui.Controls
  • SearchBoxVixen.Ui.Controls
  • SelectVixen.Ui.Controls
  • SelectBaseVixen.Ui.Controls
  • SelectionTestsVixen.Ui.Controls.Tests
  • SurfaceTestsVixen.Ui.Controls.Tests
  • SwitchVixen.Ui.Controls