Type ID

type ID struct {
	// contains filtered or unexported fields
}

ID identifies a pointer interaction region: a scope and a name. The zero ID means "no target". IDs compare with ==.

Constructors

IDFromBits#

func IDFromBits(bits uint64) ID

IDFromBits is the inverse of Bits.

Item#

func Item(n int) ID

Item returns the identity of item n in the anonymous scope: for examples, previews and tests that need a few identities and no tree of their own. Item(0) is the zero ID, "no target", so a number kept in a plain field can say so. An application with more than a screenful of controls names them in a Tree.

Methods

Bits#

func (id ID) Bits() uint64

Bits packs the identity into 64 bits, for carrying it between processes (the development reload worker and its window). The number means something only to the Tree that made it; the process that receives it may compare it and send it back, and nothing else.

In#

func (id ID) In(list Scope) (int, bool)

In returns the item number of an identity that is item i of the list scope, and false for any other identity: the way a handler reads which row was clicked.

if row, ok := id.In(rows); ok { open(row) }

IsZero#

func (id ID) IsZero() bool

IsZero reports whether the ID is "no target".

Name#

func (id ID) Name() Name

Name returns the ID's name within its scope: for an item of a list, its number.

Scope#

func (id ID) Scope() Scope

Scope returns the place the ID is in.