Boris,
Thanks for correcting my keyboard shortcut mistake
J And I suppose I got confused when looking at NSAccessibilityLinkTextAttribute since it says to specify an object (id type) for
that attribute. I’ll start with a basic NSURL object as the value and see how far that takes things.
And thanks for the pointer to AXDump about AXParagraphStyle, I’ll definitely give that a try too. I don’t suppose there’s been any discussion on here about getting Apple to
document these things? Clearly they’re getting used internally for apps like Pages… why not document them for 3rd parties as well? In general, it seems like the documentation for NSAccessibility is very limited. For example, even for the text attributes
that *are* documented, they’re documented in the old NSAccessibility (informal protocol) reference as opposed to the new (role-based protocol) one.
--Charlie
From: Boris Dusek [mailto:email@hidden]
Sent: Monday, October 12, 2015 4:18 PM
To: Charlie Powell <email@hidden>
Cc: Apple Accessibility Developer List <email@hidden>
Subject: Re: Adding support for hyperlink and alignment text attributes
Hello Charlie,
support for hyperlinks for users that want to use shortcuts like VO-Command-U
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.
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.
|