Documentation
¶
Overview ¶
Package semantics provides accessibility semantics support for Drift.
Package semantics provides accessibility semantics support for Drift. This stub implementation provides type definitions for non-supported platforms.
Index ¶
- type ActionHandler
- type CustomActionArgs
- type CustomSemanticsAction
- type MoveCursorArgs
- type SemanticsAction
- type SemanticsActions
- func (a *SemanticsActions) Clear()
- func (a *SemanticsActions) GetHandler(action SemanticsAction) ActionHandler
- func (a *SemanticsActions) HasAction(action SemanticsAction) bool
- func (a *SemanticsActions) IsEmpty() bool
- func (a *SemanticsActions) Merge(other *SemanticsActions)
- func (a *SemanticsActions) PerformAction(action SemanticsAction, args any) bool
- func (a *SemanticsActions) SetHandler(action SemanticsAction, handler ActionHandler)
- func (a *SemanticsActions) SupportedActions() SemanticsAction
- type SemanticsBinding
- func (b *SemanticsBinding) FindNodeByID(id int64) *SemanticsNode
- func (b *SemanticsBinding) FlushSemantics()
- func (b *SemanticsBinding) HandleAction(nodeID int64, action SemanticsAction, args any) bool
- func (b *SemanticsBinding) IsEnabled() bool
- func (b *SemanticsBinding) MarkNodeDirty(node *SemanticsNode)
- func (b *SemanticsBinding) Owner() *SemanticsOwner
- func (b *SemanticsBinding) RequestFullUpdate()
- func (b *SemanticsBinding) SetActionCallback(fn func(nodeID int64, action SemanticsAction, args any) bool)
- func (b *SemanticsBinding) SetEnabled(enabled bool)
- func (b *SemanticsBinding) SetOnEnabledChanged(fn func(bool))
- func (b *SemanticsBinding) SetOwner(owner *SemanticsOwner)
- func (b *SemanticsBinding) SetSendFunction(fn func(SemanticsUpdate) error)
- type SemanticsConfiguration
- type SemanticsFlag
- type SemanticsNode
- type SemanticsOwner
- type SemanticsProperties
- type SemanticsRole
- type SemanticsUpdate
- type SetSelectionArgs
- type SetTextArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionHandler ¶
type ActionHandler func(args any)
ActionHandler is a function that handles a semantics action. The args parameter contains action-specific arguments (e.g., selection range for SetSelection).
type CustomActionArgs ¶
type CustomActionArgs struct {
ActionID int64
}
CustomActionArgs contains arguments for custom actions.
type CustomSemanticsAction ¶
type CustomSemanticsAction struct {
// ID uniquely identifies this action.
ID int64
// Label is the human-readable description of the action.
Label string
}
CustomSemanticsAction defines a custom action for accessibility.
type MoveCursorArgs ¶
type MoveCursorArgs struct {
ExtendSelection bool
}
MoveCursorArgs contains arguments for cursor movement actions.
type SemanticsAction ¶
type SemanticsAction uint64
SemanticsAction represents an accessibility action that can be performed on a node.
const ( // SemanticsActionTap performs the primary action (tap/click). SemanticsActionTap SemanticsAction = 1 << iota // SemanticsActionLongPress performs a long press action. SemanticsActionLongPress // SemanticsActionScrollLeft scrolls the content left. SemanticsActionScrollLeft // SemanticsActionScrollRight scrolls the content right. SemanticsActionScrollRight // SemanticsActionScrollUp scrolls the content up. SemanticsActionScrollUp // SemanticsActionScrollDown scrolls the content down. SemanticsActionScrollDown // SemanticsActionIncrease increases the value (e.g., slider). SemanticsActionIncrease // SemanticsActionDecrease decreases the value (e.g., slider). SemanticsActionDecrease // SemanticsActionShowOnScreen scrolls this node into view. SemanticsActionShowOnScreen // SemanticsActionMoveCursorForwardByCharacter moves text cursor forward. SemanticsActionMoveCursorForwardByCharacter // SemanticsActionMoveCursorBackwardByCharacter moves text cursor backward. SemanticsActionMoveCursorBackwardByCharacter // SemanticsActionMoveCursorForwardByWord moves text cursor forward by word. SemanticsActionMoveCursorForwardByWord // SemanticsActionMoveCursorBackwardByWord moves text cursor backward by word. SemanticsActionMoveCursorBackwardByWord // SemanticsActionSetSelection sets text selection range. SemanticsActionSetSelection // SemanticsActionSetText sets the text content. SemanticsActionSetText // SemanticsActionCopy copies selected content. SemanticsActionCopy // SemanticsActionCut cuts selected content. SemanticsActionCut // SemanticsActionPaste pastes clipboard content. SemanticsActionPaste // SemanticsActionFocus requests accessibility focus. SemanticsActionFocus // SemanticsActionUnfocus removes accessibility focus. SemanticsActionUnfocus // SemanticsActionDismiss dismisses a dismissible element (e.g., dialog). SemanticsActionDismiss // SemanticsActionCustomAction performs a custom action by ID. SemanticsActionCustomAction )
func (SemanticsAction) String ¶
func (a SemanticsAction) String() string
String returns a human-readable name for the action.
type SemanticsActions ¶
type SemanticsActions struct {
// contains filtered or unexported fields
}
SemanticsActions holds action handlers for a semantics node.
func NewSemanticsActions ¶
func NewSemanticsActions() *SemanticsActions
NewSemanticsActions creates a new SemanticsActions instance.
func (*SemanticsActions) GetHandler ¶
func (a *SemanticsActions) GetHandler(action SemanticsAction) ActionHandler
GetHandler returns the handler for the given action, or nil if none.
func (*SemanticsActions) HasAction ¶
func (a *SemanticsActions) HasAction(action SemanticsAction) bool
HasAction reports whether the node has a handler for the given action.
func (*SemanticsActions) IsEmpty ¶
func (a *SemanticsActions) IsEmpty() bool
IsEmpty reports whether there are no action handlers.
func (*SemanticsActions) Merge ¶
func (a *SemanticsActions) Merge(other *SemanticsActions)
Merge combines another SemanticsActions into this one. Handlers from other override existing handlers for the same action.
func (*SemanticsActions) PerformAction ¶
func (a *SemanticsActions) PerformAction(action SemanticsAction, args any) bool
PerformAction executes the handler for the given action if it exists. Returns true if the action was handled.
func (*SemanticsActions) SetHandler ¶
func (a *SemanticsActions) SetHandler(action SemanticsAction, handler ActionHandler)
SetHandler registers a handler for the given action.
func (*SemanticsActions) SupportedActions ¶
func (a *SemanticsActions) SupportedActions() SemanticsAction
SupportedActions returns a bitmask of all supported actions.
type SemanticsBinding ¶ added in v0.5.0
type SemanticsBinding struct {
// contains filtered or unexported fields
}
SemanticsBinding connects the semantics system to platform accessibility services.
func GetSemanticsBinding ¶ added in v0.5.0
func GetSemanticsBinding() *SemanticsBinding
GetSemanticsBinding returns the global semantics binding.
func (*SemanticsBinding) FindNodeByID ¶ added in v0.5.0
func (b *SemanticsBinding) FindNodeByID(id int64) *SemanticsNode
FindNodeByID finds a semantics node by its ID.
func (*SemanticsBinding) FlushSemantics ¶ added in v0.5.0
func (b *SemanticsBinding) FlushSemantics()
FlushSemantics sends any pending semantics updates.
func (*SemanticsBinding) HandleAction ¶ added in v0.5.0
func (b *SemanticsBinding) HandleAction(nodeID int64, action SemanticsAction, args any) bool
HandleAction handles an action request from the platform.
func (*SemanticsBinding) IsEnabled ¶ added in v0.5.0
func (b *SemanticsBinding) IsEnabled() bool
IsEnabled reports whether accessibility is enabled.
func (*SemanticsBinding) MarkNodeDirty ¶ added in v0.5.0
func (b *SemanticsBinding) MarkNodeDirty(node *SemanticsNode)
MarkNodeDirty marks a specific node as needing update.
func (*SemanticsBinding) Owner ¶ added in v0.5.0
func (b *SemanticsBinding) Owner() *SemanticsOwner
Owner returns the current semantics owner.
func (*SemanticsBinding) RequestFullUpdate ¶ added in v0.5.0
func (b *SemanticsBinding) RequestFullUpdate()
RequestFullUpdate requests a full semantics tree update.
func (*SemanticsBinding) SetActionCallback ¶ added in v0.5.0
func (b *SemanticsBinding) SetActionCallback(fn func(nodeID int64, action SemanticsAction, args any) bool)
SetActionCallback sets the callback for handling actions from the platform.
func (*SemanticsBinding) SetEnabled ¶ added in v0.5.0
func (b *SemanticsBinding) SetEnabled(enabled bool)
SetEnabled enables or disables accessibility.
func (*SemanticsBinding) SetOnEnabledChanged ¶ added in v0.12.0
func (b *SemanticsBinding) SetOnEnabledChanged(fn func(bool))
SetOnEnabledChanged registers a callback invoked when accessibility is enabled or disabled.
func (*SemanticsBinding) SetOwner ¶ added in v0.5.0
func (b *SemanticsBinding) SetOwner(owner *SemanticsOwner)
SetOwner sets the semantics owner for this binding.
func (*SemanticsBinding) SetSendFunction ¶ added in v0.5.0
func (b *SemanticsBinding) SetSendFunction(fn func(SemanticsUpdate) error)
SetSendFunction sets the function used to send updates to the platform.
type SemanticsConfiguration ¶ added in v0.5.0
type SemanticsConfiguration struct {
// IsSemanticBoundary indicates this node creates a separate semantic node
// rather than merging with its ancestors.
IsSemanticBoundary bool
// IsMergingSemanticsOfDescendants indicates this node merges the semantics
// of its descendants into itself.
IsMergingSemanticsOfDescendants bool
// ExplicitChildNodes indicates whether child nodes should be explicitly
// added rather than inferred from the render tree.
ExplicitChildNodes bool
// IsBlockingUserActions indicates the node blocks user actions (e.g., modal overlay).
IsBlockingUserActions bool
// Properties contains semantic property values.
Properties SemanticsProperties
// Actions contains action handlers.
Actions *SemanticsActions
}
SemanticsConfiguration describes semantic properties and actions for a render object.
func (*SemanticsConfiguration) EnsureFocusable ¶ added in v0.5.0
func (c *SemanticsConfiguration) EnsureFocusable()
EnsureFocusable marks the configuration as focusable when it has meaningful content.
func (SemanticsConfiguration) IsEmpty ¶ added in v0.5.0
func (c SemanticsConfiguration) IsEmpty() bool
IsEmpty reports whether the configuration contains any semantic information.
func (*SemanticsConfiguration) Merge ¶ added in v0.5.0
func (c *SemanticsConfiguration) Merge(other SemanticsConfiguration)
Merge combines another configuration into this one.
type SemanticsFlag ¶
type SemanticsFlag uint64
SemanticsFlag represents boolean state flags for a semantics node.
const ( // SemanticsHasCheckedState indicates the node has a checked state. SemanticsHasCheckedState SemanticsFlag = 1 << iota // SemanticsIsChecked indicates the node is currently checked. SemanticsIsChecked // SemanticsHasSelectedState indicates the node has a selected state. SemanticsHasSelectedState // SemanticsIsSelected indicates the node is currently selected. SemanticsIsSelected // SemanticsHasEnabledState indicates the node has an enabled state. SemanticsHasEnabledState // SemanticsIsEnabled indicates the node is currently enabled. SemanticsIsEnabled // SemanticsIsFocusable indicates the node can receive focus. SemanticsIsFocusable // SemanticsIsFocused indicates the node currently has focus. SemanticsIsFocused // SemanticsIsButton indicates the node behaves as a button. SemanticsIsButton // SemanticsIsTextField indicates the node is a text field. SemanticsIsTextField // SemanticsIsReadOnly indicates the node is read-only. SemanticsIsReadOnly // SemanticsIsObscured indicates the node content is obscured (e.g., password). SemanticsIsObscured // SemanticsIsMultiline indicates the text field is multiline. SemanticsIsMultiline // SemanticsIsSlider indicates the node is a slider. SemanticsIsSlider // SemanticsIsLiveRegion indicates the node content updates should be announced. SemanticsIsLiveRegion // SemanticsHasToggledState indicates the node has a toggled state. SemanticsHasToggledState // SemanticsIsToggled indicates the node is currently toggled on. SemanticsIsToggled // SemanticsHasImplicitScrolling indicates the node has implicit scrolling. SemanticsHasImplicitScrolling // SemanticsIsHidden indicates the node is hidden from accessibility. SemanticsIsHidden // SemanticsIsHeader indicates the node is a header. SemanticsIsHeader // SemanticsIsImage indicates the node is an image. SemanticsIsImage // SemanticsNamesRoute indicates the node names a navigation route. SemanticsNamesRoute // SemanticsScopesRoute indicates the node defines a navigation route scope. SemanticsScopesRoute // SemanticsIsInMutuallyExclusiveGroup indicates exclusive selection (radio group). SemanticsIsInMutuallyExclusiveGroup // SemanticsHasExpandedState indicates the node has expanded/collapsed state. SemanticsHasExpandedState // SemanticsIsExpanded indicates the node is currently expanded. SemanticsIsExpanded )
func (SemanticsFlag) Clear ¶
func (f SemanticsFlag) Clear(flag SemanticsFlag) SemanticsFlag
Clear removes a flag.
func (SemanticsFlag) Has ¶
func (f SemanticsFlag) Has(flag SemanticsFlag) bool
Has checks if a specific flag is set.
func (SemanticsFlag) Set ¶
func (f SemanticsFlag) Set(flag SemanticsFlag) SemanticsFlag
Set adds a flag.
type SemanticsNode ¶ added in v0.5.0
type SemanticsNode struct {
// ID uniquely identifies this node.
ID int64
// Rect is the bounding rectangle in global coordinates.
Rect graphics.Rect
// Config contains the semantic configuration.
Config SemanticsConfiguration
// Parent is the parent node, or nil for root.
Parent *SemanticsNode
// Children are the child nodes.
Children []*SemanticsNode
// contains filtered or unexported fields
}
SemanticsNode represents a node in the semantics tree.
func BuildSemanticsTree ¶ added in v0.5.0
func BuildSemanticsTree(config SemanticsConfiguration, rect graphics.Rect, children ...*SemanticsNode) *SemanticsNode
BuildSemanticsTree creates a semantics tree node with children.
func NewSemanticsNode ¶ added in v0.5.0
func NewSemanticsNode() *SemanticsNode
NewSemanticsNode creates a new semantics node with a unique ID.
func NewSemanticsNodeWithID ¶ added in v0.5.0
func NewSemanticsNodeWithID(id int64) *SemanticsNode
NewSemanticsNodeWithID creates a new semantics node with a specific ID.
type SemanticsOwner ¶ added in v0.5.0
type SemanticsOwner struct {
Root *SemanticsNode
// contains filtered or unexported fields
}
SemanticsOwner manages the semantics tree and tracks dirty nodes.
func NewSemanticsOwner ¶ added in v0.5.0
func NewSemanticsOwner() *SemanticsOwner
NewSemanticsOwner creates a new semantics owner.
func (*SemanticsOwner) GetDirtyNodes ¶ added in v0.5.0
func (o *SemanticsOwner) GetDirtyNodes() []*SemanticsNode
GetDirtyNodes returns and clears all dirty nodes.
type SemanticsProperties ¶
type SemanticsProperties struct {
// Label is the primary text description of the node.
Label string
// Value is the current value (e.g., slider position, text content).
Value string
// Hint provides guidance on the action that will occur (e.g., "Double tap to activate").
Hint string
// Tooltip provides additional information shown on hover/long press.
Tooltip string
// Role defines the semantic role of the node.
Role SemanticsRole
// Flags contains boolean state flags.
Flags SemanticsFlag
// CurrentValue for slider-type controls.
CurrentValue *float64
// MinValue for slider-type controls.
MinValue *float64
// MaxValue for slider-type controls.
MaxValue *float64
// ScrollPosition for scrollable containers.
ScrollPosition *float64
// ScrollExtentMin is the minimum scroll extent.
ScrollExtentMin *float64
// ScrollExtentMax is the maximum scroll extent.
ScrollExtentMax *float64
// HeadingLevel indicates heading level (1-6, 0 for none).
HeadingLevel int
// TextSelection indicates selected text range (start, end indices).
TextSelectionStart int
TextSelectionEnd int
// SortKey is used for custom ordering in accessibility traversal.
SortKey *float64
// CustomActions is a list of custom accessibility actions.
CustomActions []CustomSemanticsAction
}
SemanticsProperties defines the semantic information for a node.
func (SemanticsProperties) IsEmpty ¶
func (p SemanticsProperties) IsEmpty() bool
IsEmpty reports whether the properties contain any meaningful semantic information.
func (SemanticsProperties) Merge ¶
func (p SemanticsProperties) Merge(other SemanticsProperties) SemanticsProperties
Merge combines another SemanticsProperties into this one. Non-empty values from other take precedence.
type SemanticsRole ¶
type SemanticsRole int
SemanticsRole indicates the role of a semantics node for accessibility purposes.
const ( // SemanticsRoleNone indicates no specific role. SemanticsRoleNone SemanticsRole = iota // SemanticsRoleButton indicates a clickable button. SemanticsRoleButton // SemanticsRoleCheckbox indicates a checkbox control. SemanticsRoleCheckbox // SemanticsRoleRadio indicates a radio button. SemanticsRoleRadio // SemanticsRoleSwitch indicates a toggle switch. SemanticsRoleSwitch // SemanticsRoleTextField indicates a text input field. SemanticsRoleTextField // SemanticsRoleLink indicates a hyperlink. SemanticsRoleLink // SemanticsRoleImage indicates an image. SemanticsRoleImage // SemanticsRoleSlider indicates a slider control. SemanticsRoleSlider // SemanticsRoleProgressIndicator indicates a progress indicator. SemanticsRoleProgressIndicator // SemanticsRoleTab indicates a tab control. SemanticsRoleTab // SemanticsRoleTabBar indicates a tab bar container. SemanticsRoleTabBar // SemanticsRoleList indicates a list container. SemanticsRoleList // SemanticsRoleListItem indicates a list item. SemanticsRoleListItem // SemanticsRoleScrollView indicates a scrollable container. SemanticsRoleScrollView // SemanticsRoleHeader indicates a header or title. SemanticsRoleHeader // SemanticsRoleAlert indicates an alert or dialog. SemanticsRoleAlert // SemanticsRoleMenu indicates a menu. SemanticsRoleMenu // SemanticsRoleMenuItem indicates a menu item. SemanticsRoleMenuItem // SemanticsRolePopup indicates a popup. SemanticsRolePopup )
func (SemanticsRole) String ¶
func (r SemanticsRole) String() string
String returns a human-readable name for the role.
type SemanticsUpdate ¶ added in v0.5.0
type SemanticsUpdate struct {
Nodes []*SemanticsNode
}
SemanticsUpdate represents an update to send to the platform.
func (SemanticsUpdate) IsEmpty ¶ added in v0.5.0
func (u SemanticsUpdate) IsEmpty() bool
IsEmpty returns true if the update has no changes.
type SetSelectionArgs ¶
SetSelectionArgs contains arguments for the SetSelection action.
type SetTextArgs ¶
type SetTextArgs struct {
Text string
}
SetTextArgs contains arguments for the SetText action.