FocusManager

Class

Tracks focusable elements within the current virtual DOM and coordinates focus changes.

Namespace: RazorConsole.Core.Focus
Assembly: RazorConsole.Core

Definition

public sealed class FocusManager : IObserver<ConsoleRenderer.RenderSnapshot>

Constructors

1
NameTypeDescription
FocusManager()Constructor—

Properties

2
NameTypeDescription
Behavior
CurrentFocusKeyStringGets the key of the currently focused element.
HasFocusablesBooleanGets a value indicating whether the manager has active focusable targets.

Methods

6
NameTypeDescription
FocusAsync(string, CancellationToken)()Task<Boolean>Attempts to focus the target that matches the supplied key. If the target does not exist in the current snapshot, the request is stored and applied when a later snapshot contains it, unless focus is moved explicitly first.
FocusNextAsync(CancellationToken)()Task<Boolean>Moves focus to the next focusable target in traversal order.
FocusPreviousAsync(CancellationToken)()Task<Boolean>Moves focus to the previous focusable target in traversal order.
IsFocused(string?)()BooleanDetermines whether the supplied focus key corresponds to the active focus target.
OnCompleted()Method—
OnError(Exception)()Method—

Events

1
NameTypeDescription
FocusChangedEventHandler<FocusChangedEventArgs>Raised when the focused element changes.