if you turn on NSAccessibilityDebugLogLevel (defaults write -g NSAccessibilityDebugLogLevel 1), you get warnings about out-of-bounds errors.
Looking at the code, it seems you made the typical mistake people do when working with AXAttributedStringForRange - the range of the string you are returning starts at 0, but it is relatively positioned at [parameter rangeValue].location offset in the global string value. You have to take that into account.
From 0c3cf797252fc9d8d414a65c219391f26070353f Mon Sep 17 00:00:00 2001
Date: Fri, 15 Aug 2014 15:53:54 +0200
Subject: [PATCH] Fix?
---
StaticTextAccessibility/STAAccessibleLinkTextField.m | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/StaticTextAccessibility/STAAccessibleLinkTextField.m b/StaticTextAccessibility/STAAccessibleLinkTextField.m
index a8beacb..8d42595 100644
--- a/StaticTextAccessibility/STAAccessibleLinkTextField.m
+++ b/StaticTextAccessibility/STAAccessibleLinkTextField.m
@@ -228,8 +228,13 @@
if (proxyObject)
{
- NSDictionary *linkAtts = @{NSAccessibilityLinkTextAttribute: proxyObject};
- [outAttString setAttributes:linkAtts range:range];
+ NSRange linkRange = NSIntersectionRange(range, [parameter rangeValue]);
+ if (linkRange.length > 0) {
+ linkRange.location -= [parameter rangeValue].location;
+
+ NSDictionary *linkAtts = @{NSAccessibilityLinkTextAttribute: proxyObject};
+ [outAttString setAttributes:linkAtts range:linkRange];
+ }
}
}
}];
--
2.0.2
You could also use std::map of link proxies to have more effective search of the link proxies, but that would pay off only for really large texts.
This change does not make the link report yet as links in VoiceOver, but at least now in console you see that there are no out-of-bounds exceptions and if you uncomment the NSLog line before return, you now see that VO successfully asks for value of AXAttributedStringForRange with ranges that are a subrange of the total range of the string (you did not see that before because exception has been thrown before the return line)
So not there yet, but definitely some progress already :-)
On Aug 15, 2014, at 3:25 PM, Nick Kocharhook <
email@hidden> wrote:
I’m trying to make links in an NSTextFieldCell subclass accessible to VoiceOver in the same way as they work in NSTextViews. I’m hoping for the “link” spoken text and the press action. We’ve got potentially tens of these on screen at a time, so we’re currently
using the much lighter-weight NSTextField instead of NSTextView. There’s also no need for scrolling or for editing, so NSTextView really would be overkill.
James outlined a way to get VO links in a StaticText, he thought, in 2008:
I did most of what he suggested, and I’ve succeeded in getting the text field to report children which appear in the Accessibility Inspector. The children aren’t correctly placed because I haven’t done the work to properly determine the glyph rects of
the links as laid out. But their rects ARE contained in the rect of the AXStaticText.
Unfortunately, I still can’t find them when using VoiceOver. :-( Here is the sample project I’ve been working on. All the code is in STAAccessibleLinkTextField:
As you can see, both selection and rich text are on. This allows the links to have the pointing finger on hover, as described in this Technical Q&A:
Please let me know what I’m missing! I feel like I should be there already, but it doesn’t quite work yet…
Thanks very much in advance,
-Nick
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden