spatial

package
v0.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package spatial ranks focusable elements by their position within the active focus scope. Navigate moves keyboard focus to a candidate in the requested direction, leaving focus unchanged when no candidate is available.

Index

Constants

View Source
const (
	// DirectionUp navigates toward the top of the screen.
	DirectionUp = dom.DirectionUp
	// DirectionDown navigates toward the bottom of the screen.
	DirectionDown = dom.DirectionDown
	// DirectionLeft navigates toward the left side of the screen.
	DirectionLeft = dom.DirectionLeft
	// DirectionRight navigates toward the right side of the screen.
	DirectionRight = dom.DirectionRight
)

Variables

This section is empty.

Functions

func Candidates

func Candidates(m *focus.Manager, dir Direction) []dom.Element

Candidates returns the focusable elements in dir from the current focus, ranked by suitability (lowest score first). It is exposed for advanced use such as showing a navigation preview. Most callers want Navigate.

func Navigate(m *focus.Manager, dir Direction) bool

Navigate moves focus in dir within the active scope of m. Returns true if focus moved to a new element, false if no suitable candidate was found (focus is unchanged).

On success, focus is set with focus.ReasonKeyboard.

Types

type Direction

type Direction = dom.Direction

Direction represents the four cardinal directions for spatial navigation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL