Skip to content

1681-engine / ui / nextFocus

Function: nextFocus() ​

ts
function nextFocus(
   rects, 
   current, 
   dir, 
   wrap?
): number;

Defined in: src/ui/layout/focusNav.ts:32

Spatial navigation (a gamepad's d-pad, the arrow keys): from current, the nearest item whose centre lies in dir, an item straight ahead preferred over a nearer one off to the side. With wrap, going past the last item comes back in from the far side on the same line. Returns current when nothing lies that way.

Parameters ​

ParameterTypeDefault value
rectsreadonly Rect[]undefined
currentnumberundefined
dirNavDirectionundefined
wrapbooleanfalse

Returns ​

number

Released under the MIT License.