Skip to content

Semantics API

Declared by <huxerui/semantics.h>.

SemanticNodeId is std::uint64_t. SemanticRole values are Generic, Text, Heading, Image, Button, Link, Checkbox, RadioButton, Switch, Slider, ProgressIndicator, TextField, SearchField, Tab, TabList, Menu, MenuItem, Dialog, Navigation, List, ListItem, Grid, GridCell, and ScrollView.

  • SemanticCheckedState: Unchecked, Checked, or Mixed.
  • SemanticLiveRegion: None, Polite, or Assertive.
  • SemanticDescendantPolicy: Preserve or Exclude.
  • Value structures: SemanticRange, SemanticCollection, and SemanticCollectionItem.

Semantics is a modifier with optional role, label, value, placeholder, hint, state description, error, identifier, checked/selected/expanded/busy/read-only/required/invalid state, heading level, range, text selection, scroll metrics, collection/item metadata, live region, descendant policy, and hidden flag.

SemanticActionKind values are Activate, Focus, SetText, SetSelection, SetValue, Increment, Decrement, Scroll, ShowOnScreen, Expand, Collapse, Dismiss, and Custom. SemanticActionMask maps a kind to its bit. SemanticAction carries a kind and typed variant payload.

SemanticNode is the fully resolved adapter record: identity/parent/children, optional platform-view identity, strings, state, range/editing/scroll/collection data, enabled/focused/multiline/secure/offscreen flags, action mask, custom actions, and world bounds. SemanticFrame contains revision, root ID, and nodes.

Extension-facing builder methods are SetOwner, AddChild(local_id, local_bounds, semantics), AddAction, and AddCustomAction. Runtime transforms local extension nodes into the final frame.

Application code supplies a Semantics{...} value through .With(...) when visual structure alone cannot express a label, role, state, or relationship. Built-in controls already provide their normal roles, values, state, and actions. Do not duplicate a visible child label unless the platform accessibility name genuinely needs a different value.

SemanticBuilder is for a custom NodeExtension; SemanticNode and SemanticFrame are resolved platform-adapter records. Actions return to Runtime on the UI thread through PerformSemanticAction. Platform exposure depends on the backend; the shared semantic tree existing does not by itself prove that a platform accessibility bridge is implemented.