Vixen
dd8b0a81
csharp
public sealed class FocusEvent

The focus arriving at or leaving an element.

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

Remarks

Routed like any other event, so an ancestor can hear that something inside it took the focus without every control having to tell it. That is what a form uses to know which field is current, and what a scroll view uses to bring it into view.

⚠ The two halves are raised on opposite sides of the change, and they were not. The losing element hears it before Focused moves and the gaining one after, which is what makes Cancel mean anything: a refusal that arrived after the focus had already left would be a report rather than a veto. So a handler on the losing leg reads the state it is losing, and one on the gaining leg reads the state it has gained; both read the event's own Previous/Next for the other end, which is what every handler in the tree already did.

Fields and properties (4)

  • public bool Gained

    Whether this element is taking the focus rather than losing it.

  • public UiElement? Previous

    What had the focus before.

  • public UiElement? Next

    What has it now.

  • public bool Cancel

    Set by a losing element to refuse to give the focus up.

Used by (21)

  • BuildContextVixen.Ui
  • ButtonBaseVixen.Ui.Controls
  • CodeEditorVixen.Ui.Controls.Advanced
  • CommandBindingTestsVixen.Ui.Controls.Tests
  • DockPanelVixen.Ui.Controls.Advanced
  • DockingHostVixen.Ui.Controls.Advanced
  • FocusTestsVixen.Ui.Tests
  • NavigationTestsVixen.Ui.Tests
  • NumericInputVixen.Ui.Controls
  • ParkedFocusTestsVixen.Ui.Tests
  • ScrollViewVixen.Ui.Controls
  • SurfaceTestsVixen.Ui.Tests
  • TextFieldVixen.Ui.Controls
  • ToolbarVixen.Ui.Controls
  • TreeViewVixen.Ui.Controls.Advanced
  • UiDocumentVixen.Ui
  • EditorApplicationVixen.Editor.App
  • MultilineDrawerVixen.Editor.Inspector
  • NodeGraphViewVixen.Editor.NodeGraph
  • SceneViewportVixen.Editor.SceneView
  • StringDrawerVixen.Editor.Inspector