Skip to content
docsv0.3.0

FocusManager

The default {@see FocusManagerInterface} implementation: modulo-wrapped rotation through a deduplicated, non-empty-string-only id list. `$index` is clamped into range at construction and on every rotation, so it can never point outside {@see ids()} even if constructed with an out-of-range starting index.

FocusManager::__construct()

public function __construct(array $ids = [], int $index = 0):

Parameters

Parameters of __construct()
NameTypeDescription
$idsarray<int, string>The focusable ids to rotate through. Deduplicated and stripped of empty strings before use.
$indexintStarting position into `$ids`, clamped into range.

FocusManager::currentId()

public function currentId(): ?string

The id currently holding focus, or null when nothing does.

FocusManager::focus()

public function focus(string $id): void

Moves focus to this id, if it is part of the focus order.

Parameters

Parameters of focus()
NameTypeDescription
$idstring

FocusManager::next()

public function next(): ?string

Moves focus to the next id in order and returns it, wrapping at the end.

FocusManager::previous()

public function previous(): ?string

Moves focus to the previous id in order and returns it, wrapping at the start.

FocusManager::ids()

public function ids(): array