Table of Contents

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

focusedWindow Window
focusedControl IInteractiveControl
changeReason FocusChangeReason

Fields

Empty

An empty focus state with nothing focused

public static readonly FocusState Empty

Field Value

FocusState

Properties

ChangeReason

The reason for the most recent focus change

public FocusChangeReason ChangeReason { get; init; }

Property Value

FocusChangeReason

FocusedControl

The currently focused control within the focused window

public IInteractiveControl? FocusedControl { get; init; }

Property Value

IInteractiveControl

FocusedWindow

The currently focused window (receives keyboard input)

public Window? FocusedWindow { get; init; }

Property Value

Window

UpdateTime

Timestamp when this state was created

public DateTime UpdateTime { get; init; }

Property Value

DateTime

Methods

HasChanged(FocusState)

Returns true if any focus state has changed compared to another state

public bool HasChanged(FocusState other)

Parameters

other FocusState

Returns

bool

HasControlChanged(FocusState)

Returns true if the focused control has changed compared to another state

public bool HasControlChanged(FocusState other)

Parameters

other FocusState

Returns

bool

HasWindowChanged(FocusState)

Returns true if the focused window has changed compared to another state

public bool HasWindowChanged(FocusState other)

Parameters

other FocusState

Returns

bool