Skip to content

feat(macos): Mark link text in attributed strings - #831

Open
xiaolai wants to merge 1 commit into
AccessKit:mainfrom
xiaolai:macos-link-text-attribute
Open

xiaolai wants to merge 1 commit into
AccessKit:mainfrom
xiaolai:macos-link-text-attribute

Conversation

@xiaolai

@xiaolai xiaolai commented Oct 18, 2026

Copy link
Copy Markdown

What

accessibilityAttributedStringForRange: returns font, colour, decoration and language attributes, but nothing marks text that belongs to a link. AppKit's own text views mark it with NSAccessibilityLinkTextAttribute (AXLink), whose value is the link element; assistive technologies use it to announce and reach inline links while reading a paragraph.

This PR adds that attribute: for each text run in the range, if the run has a Role::Link ancestor below the node being queried, the run's attributes include AXLink set to that link's platform node.

Testing

On macOS 27 (Apple silicon), with a winit host exposing a paragraph as a Label whose TextRun children include runs inside a Link node, queried through AXUIElement:

  • before: AXAttributedStringForRange over the whole paragraph carries no AXLink attribute;
  • after: exactly the link's 18 characters carry AXLink, and its value is the same element as the paragraph's AXLink child.

cargo fmt --check, cargo clippy -p accesskit_macos --all-targets -- -D warnings and cargo test -p accesskit_macos pass. The adapter has no unit tests to extend; I have not built with Rust 1.87 locally, and nothing here uses newer language or library features. VoiceOver itself has not yet been run against this build.

Text inside a Link node now carries NSAccessibilityLinkTextAttribute
(AXLink) in accessibilityAttributedStringForRange:, whose value is the
link's own platform element. This is how AppKit text views expose
hypertext, and it lets an assistive technology announce and reach an
inline link while reading the surrounding text.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant