ui

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 2 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 ui is the platform-neutral screen model: a tree of nodes read from a device.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coll

type Coll struct{ Rows, Cols int }

Coll is a list's size (Rows, Cols; -1 unknown) or an item's row and column in one.

type Node

type Node struct {
	Text  string // Android text / iOS title or value
	Desc  string // Android content-description / iOS label (accessibilityText in selectors)
	ID    string // Android resource-id / iOS accessibilityIdentifier
	Hint  string // placeholder
	Value string // iOS value
	Error string
	State string // Android stateDescription
	Class string // Android class name / iOS element type

	Bounds Rect

	Clickable, LongClickable, Enabled, Focused, Checked, Checkable, Selected bool
	Scrollable, Password, Editable, Visible, ShowingHint                     bool

	// Android scroll containers: whether it can scroll further (forward = down or right),
	// and a list's size / an item's row and column in it, when the app reports them.
	MoreAfter, MoreBefore bool
	Coll, Item            *Coll

	Window   int // index of its window in Screen.Windows
	Depth    int // depth within its window
	Index    int // pre-order position in Screen.Nodes
	Parent   *Node
	Children []*Node
}

Node is one element on screen.

func (*Node) ClipRect

func (n *Node) ClipRect(screen Rect) Rect

ClipRect is the part of the screen where n can show: the screen, cut to every scrolling ancestor's bounds (a row scrolled out of its list is not on screen, though inside the screen). Ignored: ancestors with empty bounds, and a window's root, whose scrolling is the window's own (a web page's body: its box moves up off the screen as the page scrolls, while what shows is the window).

func (*Node) IsDescendantOf

func (n *Node) IsDescendantOf(anc *Node) bool

IsDescendantOf reports whether n is anc or inside it.

func (*Node) Label

func (n *Node) Label() string

Label is what a person reads on the node: its text, else its accessibility description.

func (*Node) ShortClass

func (n *Node) ShortClass() string

ShortClass is the last segment of the class name.

func (*Node) Walk

func (n *Node) Walk(fn func(*Node) bool)

Walk visits n and its subtree in pre-order. Returning false skips a node's children.

type Rect

type Rect struct{ L, T, R, B int }

func (Rect) Area

func (r Rect) Area() int

func (Rect) CX

func (r Rect) CX() int

func (Rect) CY

func (r Rect) CY() int

func (Rect) Contains

func (r Rect) Contains(x, y int) bool

func (Rect) Empty

func (r Rect) Empty() bool

func (Rect) H

func (r Rect) H() int

func (Rect) Intersect

func (r Rect) Intersect(o Rect) Rect

func (Rect) Overlaps

func (r Rect) Overlaps(o Rect) bool

func (Rect) String

func (r Rect) String() string

func (Rect) W

func (r Rect) W() int

type Screen

type Screen struct {
	Platform string
	Width    int
	Height   int
	Seq      int64 // the device's change counter when it was read
	Keyboard bool
	Windows  []*Window // top-most first
	Nodes    []*Node   // every node, pre-order, windows top-most first
}

Screen is one read of the device's screen.

func (*Screen) Foreground

func (s *Screen) Foreground() string

Foreground is the package or bundle id of the active app window.

func (s *Screen) Link()

Link fills Parent, Children, Index and Window from each node's Depth, given nodes per window in pre-order.

func (*Screen) Signature

func (s *Screen) Signature() uint64

Signature hashes what the screen shows (structure, text, bounds, state), to tell whether two reads differ.

type Window

type Window struct {
	ID      int
	Type    string // app, keyboard, system, overlay
	Package string
	Title   string
	Active  bool
	Focused bool
	Bounds  Rect
	Nodes   []*Node // this window's nodes, pre-order with Depth set (input to Link)
	Roots   []*Node
}

Window is one window (an app, the keyboard, a system dialog).

Jump to

Keyboard shortcuts

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