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

7
NameTypeDescription
BeginSession(ConsoleLiveDisplayContext, ConsoleViewResult, CancellationToken)()FocusSessionBegins a new focus session that tracks updates on the provided live display context.
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 retried on the next snapshot update only.
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.