Hello Charlie,support for hyperlinks for users that want to use shortcuts like VO-Command-U
and VO-Cmd-L :-) and similarly for paragraph alignment information when doing VO-T (left/center/right aligned).
You should use a “AXParagraphStyle” attribute like, its value being a dictionary. In this dictionary, you can specify a key “AXTextAlignment” with values being NSNumbers of NSTextAlignment.
I had originally assumed that NSAccessibilityLinkTextAttribute was what I needed for hyperlinks, but it seems that’s actually intended for the VO-J shortcut to move focus to another element entirely.
What you are describing sounds more like NSAccessibilityLinkedUIElementsAttribute.
AFAIK, NSAccessibilityLinkTextAttribute is for hyperlinks, i.e. navigating with VO-Cmd-L, reading the URL with VO-Shift-U, activating with VO-Space (even though last time I tried, and that was already quite a long ago, this one seems to be a bit unreliable and act up). E.g. TextMate 2 does support VO-Cmd-L for links (e.g. in HTML in “href" attribute of “a” element), thanks to setting NSAccessibilityLinkTextAttribute: https://github.com/textmate/textmate/blob/master/Frameworks/OakTextView/src/OakTextView.mm#L1492
I think you can either set the value of the attribute to a URL directly (with limited functionality), or to an accessibility object (with more functionality; e.g. like OakAccesibleLink in the above linked file) which are children of the AXTextArea (you can inspect them in this way in e.g. TextEdit). I haven’t been doing much work with these lately, therefore cannot be more specific, so feel free to experiment. Pages and TextEdit seem to have support for this and alignment, but I can’t find anything in the documentation about how to support it.
You can use the above-mentioned AXDump in most cases to learn what text attributes these programs use for undocumented accessibility features that however are supported by VoiceOver. Just be warned that what you deduce in this way can be undocumented, i.e. not public API, and therefore subject to change; however the motivation to use these when VoiceOver supports them for useful functionality is also clear.
Hope this helps,
Boris Dušek
P.S.: If someone knows of something like AXDump but more user-friendly, please let me know. Unfortunately UI Browser, which would be in principle ideal for this, seems to display attributed text only in rendered form, not the “raw” attributed form - at least I could not achieve the latter. So to learn the raw attributes, I had to resort to writing the not-so-much developer-friendly AXDump, which however does the job. |