Documentation
¶
Overview ¶
Package accessibility provides accessibility primitives for widgets.
Index ¶
- func BoolPtr(value bool) *bool
- func FormatChange(widget Accessible) string
- type Accessible
- type Announcement
- type Announcer
- type Base
- func (b *Base) AccessibleActiveDescendant() string
- func (b *Base) AccessibleAtomic() bool
- func (b *Base) AccessibleAutocomplete() string
- func (b *Base) AccessibleControls() string
- func (b *Base) AccessibleCurrent() string
- func (b *Base) AccessibleDescribedBy() string
- func (b *Base) AccessibleDescription() string
- func (b *Base) AccessibleDetails() string
- func (b *Base) AccessibleErrorMessage() string
- func (b *Base) AccessibleFlowTo() string
- func (b *Base) AccessibleHasPopup() string
- func (b *Base) AccessibleKeyShortcuts() string
- func (b *Base) AccessibleLabel() string
- func (b *Base) AccessibleLabelledBy() string
- func (b *Base) AccessibleLandmark() Landmark
- func (b *Base) AccessibleLevel() int
- func (b *Base) AccessibleLive() Live
- func (b *Base) AccessibleOrientation() string
- func (b *Base) AccessibleOwns() string
- func (b *Base) AccessiblePlaceholder() string
- func (b *Base) AccessiblePosInSet() int
- func (b *Base) AccessibleRelevant() Relevant
- func (b *Base) AccessibleRole() Role
- func (b *Base) AccessibleRoleDescription() string
- func (b *Base) AccessibleSetSize() int
- func (b *Base) AccessibleSort() string
- func (b *Base) AccessibleState() StateSet
- func (b *Base) AccessibleValue() *ValueInfo
- func (b *Base) HasExtendedARIA() bool
- func (b *Base) SetActiveDescendant(id string)
- func (b *Base) SetAtomic(atomic bool)
- func (b *Base) SetAutocomplete(autocomplete string)
- func (b *Base) SetControls(id string)
- func (b *Base) SetCurrent(current string)
- func (b *Base) SetDescribedBy(id string)
- func (b *Base) SetDescription(description string)
- func (b *Base) SetDetails(id string)
- func (b *Base) SetErrorMessage(id string)
- func (b *Base) SetFlowTo(id string)
- func (b *Base) SetHasPopup(popup string)
- func (b *Base) SetKeyShortcuts(shortcuts string)
- func (b *Base) SetLabel(label string)
- func (b *Base) SetLabelledBy(id string)
- func (b *Base) SetLandmark(landmark Landmark)
- func (b *Base) SetLevel(level int)
- func (b *Base) SetLive(live Live)
- func (b *Base) SetOrientation(orientation string)
- func (b *Base) SetOwns(id string)
- func (b *Base) SetPlaceholder(placeholder string)
- func (b *Base) SetPosInSet(pos int)
- func (b *Base) SetRelevant(relevant Relevant)
- func (b *Base) SetRole(role Role)
- func (b *Base) SetRoleDescription(desc string)
- func (b *Base) SetSetSize(size int)
- func (b *Base) SetSort(sort string)
- func (b *Base) SetState(state StateSet)
- func (b *Base) SetValue(value *ValueInfo)
- type Bridge
- type BridgeAnnouncer
- type BridgeApp
- type FocusStyle
- type Landmark
- type Live
- type Priority
- type Relevant
- type Role
- type SimpleAnnouncer
- func (a *SimpleAnnouncer) Announce(message string, priority Priority)
- func (a *SimpleAnnouncer) AnnounceChange(widget Accessible)
- func (a *SimpleAnnouncer) CloseSpeaker()
- func (a *SimpleAnnouncer) History() []Announcement
- func (a *SimpleAnnouncer) SetOnMessage(fn func(Announcement))
- func (a *SimpleAnnouncer) SetSpeaker(s Speaker)
- type Speaker
- type StateSet
- type ValueInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatChange ¶
func FormatChange(widget Accessible) string
FormatChange builds a short description of a widget's state.
Types ¶
type Accessible ¶
type Accessible interface {
// Identity
AccessibleRole() Role
AccessibleLabel() string
AccessibleDescription() string
AccessibleState() StateSet
AccessibleValue() *ValueInfo
// Live regions — mirrors aria-live, aria-relevant, aria-atomic
AccessibleLive() Live
AccessibleRelevant() Relevant
AccessibleAtomic() bool
// Landmarks — mirrors ARIA landmark roles
AccessibleLandmark() Landmark
// Relationships — mirrors aria-labelledby, aria-describedby, aria-controls, aria-owns, aria-flowto
AccessibleLabelledBy() string
AccessibleDescribedBy() string
AccessibleControls() string
AccessibleOwns() string
AccessibleFlowTo() string
// WAI-ARIA 1.2/1.3 properties
AccessibleLevel() int
AccessibleOrientation() string
AccessibleActiveDescendant() string
AccessiblePosInSet() int
AccessibleSetSize() int
AccessibleHasPopup() string
AccessibleErrorMessage() string
AccessibleCurrent() string
AccessibleAutocomplete() string
AccessiblePlaceholder() string
AccessibleSort() string
AccessibleKeyShortcuts() string
AccessibleDetails() string
AccessibleRoleDescription() string
}
Accessible is implemented by widgets that expose accessibility metadata.
type Announcement ¶
Announcement captures a published accessibility message.
type Announcer ¶
type Announcer interface {
Announce(message string, priority Priority)
AnnounceChange(widget Accessible)
}
Announcer publishes accessibility announcements.
type Base ¶
type Base struct {
Role Role
Label string
Description string
State StateSet
Value *ValueInfo
// Live region behavior (aria-live, aria-relevant, aria-atomic)
Live Live
Relevant Relevant
Atomic bool
// Relationships (aria-labelledby, aria-describedby, aria-controls, aria-owns, aria-flowto)
LabelledBy string
DescribedBy string
Controls string
Owns string
FlowTo string
// Landmark (aria landmark roles)
Landmark Landmark
// WAI-ARIA 1.2/1.3 properties
Level int // aria-level (heading level, tree depth)
Orientation string // aria-orientation (horizontal/vertical)
ActiveDescendant string // aria-activedescendant (ID of focused descendant)
PosInSet int // aria-posinset (position in set, 1-based)
SetSize int // aria-setsize (total items in set)
HasPopup string // aria-haspopup (false/true/menu/listbox/tree/grid/dialog)
ErrorMessage string // aria-errormessage (ID of error element)
Current string // aria-current (page/step/location/date/time/true)
Autocomplete string // aria-autocomplete (inline/list/both/none)
Placeholder string // aria-placeholder
Sort string // aria-sort (ascending/descending/none/other)
KeyShortcuts string // aria-keyshortcuts
Details string // aria-details (ID of detailed description)
RoleDescription string // aria-roledescription (custom role label for AT)
}
Base is a helper implementation of Accessible.
func (*Base) AccessibleActiveDescendant ¶
AccessibleActiveDescendant returns the ID of the active descendant.
func (*Base) AccessibleAtomic ¶
AccessibleAtomic returns whether the entire region is announced on change.
func (*Base) AccessibleAutocomplete ¶
AccessibleAutocomplete returns the autocomplete mode.
func (*Base) AccessibleControls ¶
AccessibleControls returns the ID of the widget this one controls.
func (*Base) AccessibleCurrent ¶
AccessibleCurrent returns the current indicator (page/step/location/date/time/true).
func (*Base) AccessibleDescribedBy ¶
AccessibleDescribedBy returns the ID of the widget that describes this one.
func (*Base) AccessibleDescription ¶
AccessibleDescription returns the current description.
func (*Base) AccessibleDetails ¶
AccessibleDetails returns the ID of the details element.
func (*Base) AccessibleErrorMessage ¶
AccessibleErrorMessage returns the ID of the error message element.
func (*Base) AccessibleFlowTo ¶
AccessibleFlowTo returns the ID of the next widget in reading order.
func (*Base) AccessibleHasPopup ¶
AccessibleHasPopup returns the popup type.
func (*Base) AccessibleKeyShortcuts ¶
AccessibleKeyShortcuts returns the keyboard shortcuts.
func (*Base) AccessibleLabel ¶
AccessibleLabel returns the current label.
func (*Base) AccessibleLabelledBy ¶
AccessibleLabelledBy returns the ID of the widget that labels this one.
func (*Base) AccessibleLandmark ¶
AccessibleLandmark returns the landmark designation.
func (*Base) AccessibleLevel ¶
AccessibleLevel returns the heading level or tree depth.
func (*Base) AccessibleLive ¶
AccessibleLive returns the live region behavior.
func (*Base) AccessibleOrientation ¶
AccessibleOrientation returns the orientation (horizontal/vertical).
func (*Base) AccessibleOwns ¶
AccessibleOwns returns the ID of the widget this one owns.
func (*Base) AccessiblePlaceholder ¶
AccessiblePlaceholder returns the placeholder text.
func (*Base) AccessiblePosInSet ¶
AccessiblePosInSet returns the 1-based position in the set.
func (*Base) AccessibleRelevant ¶
AccessibleRelevant returns which mutations trigger announcements.
func (*Base) AccessibleRole ¶
AccessibleRole returns the current role.
func (*Base) AccessibleRoleDescription ¶
AccessibleRoleDescription returns the custom role description.
func (*Base) AccessibleSetSize ¶
AccessibleSetSize returns the total items in the set.
func (*Base) AccessibleSort ¶
AccessibleSort returns the sort direction.
func (*Base) AccessibleState ¶
AccessibleState returns the current state set.
func (*Base) AccessibleValue ¶
AccessibleValue returns the current value info.
func (*Base) HasExtendedARIA ¶
HasExtendedARIA returns true if any WAI-ARIA 1.2/1.3 extended properties are set. This allows callers to skip serialization/processing of extended properties when none are in use.
func (*Base) SetActiveDescendant ¶
SetActiveDescendant updates the ID of the active descendant.
func (*Base) SetAutocomplete ¶
SetAutocomplete updates the autocomplete mode.
func (*Base) SetControls ¶
SetControls updates the ID of the widget this one controls.
func (*Base) SetCurrent ¶
SetCurrent updates the current indicator.
func (*Base) SetDescribedBy ¶
SetDescribedBy updates the ID of the widget that describes this one.
func (*Base) SetDescription ¶
SetDescription updates the description.
func (*Base) SetDetails ¶
SetDetails updates the ID of the details element.
func (*Base) SetErrorMessage ¶
SetErrorMessage updates the ID of the error message element.
func (*Base) SetHasPopup ¶
SetHasPopup updates the popup type.
func (*Base) SetKeyShortcuts ¶
SetKeyShortcuts updates the keyboard shortcuts.
func (*Base) SetLabelledBy ¶
SetLabelledBy updates the ID of the widget that labels this one.
func (*Base) SetLandmark ¶
SetLandmark updates the landmark designation.
func (*Base) SetOrientation ¶
SetOrientation updates the orientation.
func (*Base) SetPlaceholder ¶
SetPlaceholder updates the placeholder text.
func (*Base) SetPosInSet ¶
SetPosInSet updates the 1-based position in the set.
func (*Base) SetRelevant ¶
SetRelevant updates which mutations trigger announcements.
func (*Base) SetRoleDescription ¶
SetRoleDescription updates the custom role description.
func (*Base) SetSetSize ¶
SetSetSize updates the total items in the set.
type Bridge ¶
type Bridge interface {
// Register connects the application to the platform accessibility system.
// The app parameter provides access to the widget tree.
Register(app BridgeApp) error
// Announce sends text to the screen reader.
// Priority controls whether the message interrupts current speech.
Announce(text string, priority Priority) error
// UpdateTree notifies the screen reader that the widget structure changed.
// Call this after layout changes.
UpdateTree() error
// NotifyFocusChange informs the screen reader that focus moved to a new widget.
NotifyFocusChange(widget Accessible) error
// NotifyValueChange informs the screen reader that a widget's value changed.
// For text inputs, sliders, progress bars, etc.
NotifyValueChange(widget Accessible, oldValue, newValue string) error
// NotifyStateChange informs the screen reader that a widget's state changed.
// For checkboxes, expandable items, etc.
NotifyStateChange(widget Accessible, state string, value bool) error
// Close disconnects from the platform accessibility system.
Close() error
}
Bridge provides cross-platform screen reader integration. Implementations connect to platform-specific accessibility APIs: - Linux: AT-SPI via D-Bus - macOS: NSAccessibility - Windows: UI Automation
type BridgeAnnouncer ¶
type BridgeAnnouncer struct {
// contains filtered or unexported fields
}
BridgeAnnouncer wraps a Bridge to implement the Announcer interface.
func NewBridgeAnnouncer ¶
func NewBridgeAnnouncer(bridge Bridge) *BridgeAnnouncer
NewBridgeAnnouncer creates an Announcer that uses the given Bridge.
func (*BridgeAnnouncer) Announce ¶
func (ba *BridgeAnnouncer) Announce(message string, priority Priority)
Announce sends text to the screen reader.
func (*BridgeAnnouncer) AnnounceChange ¶
func (ba *BridgeAnnouncer) AnnounceChange(widget Accessible)
AnnounceChange announces the widget state.
type BridgeApp ¶
type BridgeApp interface {
// Name returns the application name.
Name() string
// RootAccessible returns the root accessible element.
RootAccessible() Accessible
// FocusedAccessible returns the currently focused element.
FocusedAccessible() Accessible
// AccessibleAt returns the accessible at the given path.
// Path is a slash-separated list of indices from root.
AccessibleAt(path string) Accessible
// ChildAccessibles returns the children of the given accessible.
ChildAccessibles(parent Accessible) []Accessible
}
BridgeApp provides the bridge with access to application state.
type FocusStyle ¶
FocusStyle defines consistent focus rendering.
type Landmark ¶
type Landmark string
Landmark describes the structural significance of a widget for navigation. Mirrors ARIA landmark roles: navigation, main, search, form, banner, etc.
type Live ¶
type Live string
Live describes how content changes are announced to assistive technology. Mirrors aria-live: off (default), polite (wait for idle), assertive (interrupt).
type Priority ¶
type Priority int
Priority describes announcement urgency.
const ( // PriorityPolite waits for current speech to complete. PriorityPolite Priority = iota // PriorityAssertive interrupts current speech for important messages. PriorityAssertive // PriorityLow is lower than polite, can be dropped. PriorityLow // PriorityMedium is equivalent to PriorityPolite. PriorityMedium // PriorityHigh is between polite and assertive. PriorityHigh // PriorityUrgent interrupts current speech immediately. PriorityUrgent )
type Relevant ¶
type Relevant string
Relevant describes which mutations in a live region trigger announcements. Mirrors aria-relevant: additions, removals, text, all.
const ( // RelevantAdditions announces new children added to the region. RelevantAdditions Relevant = "additions" // RelevantRemovals announces children removed from the region. RelevantRemovals Relevant = "removals" // RelevantText announces text content changes. RelevantText Relevant = "text" // RelevantAll announces all mutations. RelevantAll Relevant = "all" )
type Role ¶
type Role string
Role describes the semantic role of a widget.
const ( RoleButton Role = "button" RoleCheckbox Role = "checkbox" RoleRadio Role = "radio" RoleTextbox Role = "textbox" RoleList Role = "list" RoleListItem Role = "listitem" RoleTable Role = "table" RoleRow Role = "row" RoleCell Role = "cell" RoleSlider Role = "slider" RoleTree Role = "tree" RoleTreeItem Role = "treeitem" RoleMenu Role = "menu" RoleMenuItem Role = "menuitem" RoleTab Role = "tab" RoleTabList Role = "tablist" RoleTabPanel Role = "tabpanel" RoleDialog Role = "dialog" RoleAlert Role = "alert" RoleStatus Role = "status" RoleProgressBar Role = "progressbar" RoleGroup Role = "group" RoleText Role = "text" RoleChart Role = "chart" RoleWindow Role = "window" RoleApplication Role = "application" // WAI-ARIA 1.2 additional roles RoleCombobox Role = "combobox" RoleSwitch Role = "switch" RoleSpinButton Role = "spinbutton" RoleHeading Role = "heading" RoleLink Role = "link" RoleSeparator Role = "separator" RoleLog Role = "log" RoleTimer Role = "timer" RoleFeed Role = "feed" RoleToolbar Role = "toolbar" RoleSearchbox Role = "searchbox" RoleNone Role = "none" RoleImg Role = "img" RoleNote Role = "note" RoleScrollbar Role = "scrollbar" // WAI-ARIA 1.2 composite and structural roles RoleListbox Role = "listbox" RoleOption Role = "option" RoleRadioGroup Role = "radiogroup" RoleGrid Role = "grid" RoleGridCell Role = "gridcell" RoleColumnHeader Role = "columnheader" RoleRowHeader Role = "rowheader" RoleRowGroup Role = "rowgroup" RoleAlertDialog Role = "alertdialog" RoleMenuItemCheckbox Role = "menuitemcheckbox" RoleMenuItemRadio Role = "menuitemradio" RoleMenuBar Role = "menubar" RoleTreeGrid Role = "treegrid" RoleDocument Role = "document" RoleMarquee Role = "marquee" RolePresentation Role = "presentation" RoleTooltip Role = "tooltip" RoleMeter Role = "meter" // WAI-ARIA landmark roles RoleForm Role = "form" RoleComplementary Role = "complementary" // WAI-ARIA 1.3 roles RoleComment Role = "comment" RoleMark Role = "mark" RoleSuggestion Role = "suggestion" RoleCode Role = "code" RoleTime Role = "time" RoleImage Role = "image" )
Common accessibility roles.
type SimpleAnnouncer ¶
type SimpleAnnouncer struct {
// contains filtered or unexported fields
}
SimpleAnnouncer stores announcements in memory.
func (*SimpleAnnouncer) Announce ¶
func (a *SimpleAnnouncer) Announce(message string, priority Priority)
Announce publishes a message.
func (*SimpleAnnouncer) AnnounceChange ¶
func (a *SimpleAnnouncer) AnnounceChange(widget Accessible)
AnnounceChange announces the widget state.
func (*SimpleAnnouncer) CloseSpeaker ¶
func (a *SimpleAnnouncer) CloseSpeaker()
CloseSpeaker stops any pending speech and closes the speaker.
func (*SimpleAnnouncer) History ¶
func (a *SimpleAnnouncer) History() []Announcement
History returns a copy of announcements.
func (*SimpleAnnouncer) SetOnMessage ¶
func (a *SimpleAnnouncer) SetOnMessage(fn func(Announcement))
SetOnMessage sets a callback for new announcements.
func (*SimpleAnnouncer) SetSpeaker ¶
func (a *SimpleAnnouncer) SetSpeaker(s Speaker)
SetSpeaker attaches a TTS speaker to the announcer. When set, announcements are automatically spoken.
type Speaker ¶
type Speaker interface {
// Speak sends text to the TTS engine. It blocks until speech completes
// or ctx is cancelled.
Speak(ctx context.Context, text string) error
// Stop cancels any in-progress speech.
Stop() error
// Close releases TTS resources.
Close() error
}
Speaker provides text-to-speech output. Implementations wrap platform-specific TTS engines.
type StateSet ¶
type StateSet struct {
Checked *bool // nil = not applicable
Expanded *bool
Pressed *bool // nil = not applicable (tri-state, for toggle buttons)
Selected bool
Disabled bool
ReadOnly bool
Required bool
Invalid bool
Hidden bool
Busy bool
Modal bool
Multiline bool // aria-multiline
Multiselectable bool // aria-multiselectable
}
StateSet describes the state of a widget.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package atspi provides Linux accessibility support via AT-SPI D-Bus.
|
Package atspi provides Linux accessibility support via AT-SPI D-Bus. |
|
Package nsaccessibility provides macOS accessibility support via NSAccessibility.
|
Package nsaccessibility provides macOS accessibility support via NSAccessibility. |
|
Package tts provides platform TTS backends implementing accessibility.Speaker.
|
Package tts provides platform TTS backends implementing accessibility.Speaker. |
|
Package uiautomation provides Windows accessibility support via UI Automation.
|
Package uiautomation provides Windows accessibility support via UI Automation. |