focus
Package focus provides focus management structures.
type FocusManager
FocusManager manages the global focus state.
type FocusManager struct {
RootScope *FocusScopeNode
PrimaryFocus *FocusNode
}
func GetFocusManager
func GetFocusManager() *FocusManager
GetFocusManager returns the singleton focus manager.
func (*FocusManager) MoveFocus
func (m *FocusManager) MoveFocus(delta int) bool
MoveFocus moves focus by delta positions within the root scope.
type FocusNode
FocusNode represents a focusable element in the tree.
type FocusNode struct {
CanRequestFocus bool
SkipTraversal bool
DebugLabel string
OnFocusChange func(hasFocus bool)
OnKeyEvent func(event KeyEvent) KeyEventResult
// Rect provides the geometry for directional focus navigation.
Rect RectProvider
// SemanticsLabel provides the accessibility label for this focus node.
SemanticsLabel string
// SemanticsHint provides the accessibility hint for this focus node.
SemanticsHint string
// SemanticsNodeID links this focus node to a semantics node ID.
SemanticsNodeID int64
// contains filtered or unexported fields
}
func (*FocusNode) HasFocus
func (n *FocusNode) HasFocus() bool
HasFocus reports whether this node or a descendant has focus.
func (*FocusNode) HasPrimaryFocus
func (n *FocusNode) HasPrimaryFocus() bool
HasPrimaryFocus reports whether this node is the primary focus.
func (*FocusNode) NextFocus
func (n *FocusNode) NextFocus() bool
NextFocus moves focus to the next focusable node.
func (*FocusNode) PreviousFocus
func (n *FocusNode) PreviousFocus() bool
PreviousFocus moves focus to the previous focusable node.
func (*FocusNode) RequestFocus
func (n *FocusNode) RequestFocus()
RequestFocus requests that this node receive primary focus.
func (*FocusNode) Unfocus
func (n *FocusNode) Unfocus()
Unfocus removes focus from this node if it has primary focus.
type FocusRect
FocusRect represents a rectangle for focus geometry calculations.
type FocusRect struct {
Left, Top, Right, Bottom float64
}
func (FocusRect) Center
func (r FocusRect) Center() (x, y float64)
Center returns the center point of the rectangle.
func (FocusRect) IsValid
func (r FocusRect) IsValid() bool
IsValid returns true if the rect has positive dimensions.
type FocusScopeNode
FocusScopeNode groups focus nodes.
type FocusScopeNode struct {
FocusNode
FocusedChild *FocusNode
Children []*FocusNode
}
func (*FocusScopeNode) FocusInDirection
func (s *FocusScopeNode) FocusInDirection(direction TraversalDirection)
FocusInDirection moves focus in the given direction.
func (*FocusScopeNode) SetFirstFocus
func (s *FocusScopeNode) SetFirstFocus()
SetFirstFocus sets focus to the first focusable child.
type KeyEvent
KeyEvent represents a keyboard event placeholder.
type KeyEvent struct{}
type KeyEventResult
KeyEventResult indicates how a key event was handled.
type KeyEventResult int
const (
// KeyEventIgnored indicates the event was not handled.
KeyEventIgnored KeyEventResult = iota
// KeyEventHandled indicates the event was consumed.
KeyEventHandled
)
type RectProvider
RectProvider is implemented by elements that can provide their geometry.
type RectProvider interface {
FocusRect() FocusRect
}
type TraversalDirection
TraversalDirection indicates the focus traversal direction.
type TraversalDirection int
const (
// TraversalDirectionUp moves focus upward.
TraversalDirectionUp TraversalDirection = iota
// TraversalDirectionDown moves focus downward.
TraversalDirectionDown
// TraversalDirectionLeft moves focus leftward.
TraversalDirectionLeft
// TraversalDirectionRight moves focus rightward.
TraversalDirectionRight
)
Generated by gomarkdoc