Class FocusState
- Namespace
- SharpConsoleUI.Core
- Assembly
- SharpConsoleUI.dll
Immutable record representing the current focus state. Provides a single source of truth for focus across the window system.
public record FocusState : IEquatable<FocusState>
- Inheritance
-
FocusState
- Implements
- Inherited Members
Constructors
FocusState(Window?, IInteractiveControl?, FocusChangeReason)
Creates a new focus state
public FocusState(Window? focusedWindow = null, IInteractiveControl? focusedControl = null, FocusChangeReason changeReason = FocusChangeReason.Programmatic)
Parameters
focusedWindowWindowfocusedControlIInteractiveControlchangeReasonFocusChangeReason
Fields
Empty
An empty focus state with nothing focused
public static readonly FocusState Empty
Field Value
Properties
ChangeReason
The reason for the most recent focus change
public FocusChangeReason ChangeReason { get; init; }
Property Value
FocusedControl
The currently focused control within the focused window
public IInteractiveControl? FocusedControl { get; init; }
Property Value
FocusedWindow
The currently focused window (receives keyboard input)
public Window? FocusedWindow { get; init; }
Property Value
UpdateTime
Timestamp when this state was created
public DateTime UpdateTime { get; init; }
Property Value
Methods
HasChanged(FocusState)
Returns true if any focus state has changed compared to another state
public bool HasChanged(FocusState other)
Parameters
otherFocusState
Returns
HasControlChanged(FocusState)
Returns true if the focused control has changed compared to another state
public bool HasControlChanged(FocusState other)
Parameters
otherFocusState
Returns
HasWindowChanged(FocusState)
Returns true if the focused window has changed compared to another state
public bool HasWindowChanged(FocusState other)
Parameters
otherFocusState