Changing accessibilityAttributedString for NSTextView
Changing accessibilityAttributedString for NSTextView
- Subject: Changing accessibilityAttributedString for NSTextView
- From: Vincenzo Rubano <email@hidden>
- Date: Sat, 04 Aug 2018 16:48:14 +0200
Hi all,
I am working on a mac project where I need to customize the accessibility
experience offered by the NSTextView. More specifically, our app will use some
special characters as markers. I’d like Voiceover to read the marker
description rather than a non-sense description of that character whenever the
marker should be spoken (i.e. moving the cursor character-by-character, reading
the text line-by-line). What would the correct strategy to achieve this goal
be, considering the fact that I am using a native Cocoa NSTextView? I’ve tried
reading the NSAccessibility documentation, but it’s far from clear when it
comes to supporting text editing.
In my NSTextView subclass, I’ve tried overriding
func accessibility String ( for : NSRange) -> String?
but I’ve noticed that my implementation never gets called.
I’ve also tried overriding
func accessibility Attributed String ( for : NSRange) -> NSAttributed String?
and the method gets called. The problem though is that if i replace the marker
with its description reading the text line-by-line gives the expected results,
while reading character-by-character does not work as I would expect it to. In
fact, the marker description is spelled out character-by-character rather than
being announced as a single sentence. How can I fix this behavior?
I thought I had to adjust something in the method
func accessibility Range ( for : Int) -> NSRange
but it never gets called, so that’s not the way to go I suppose.
I’ve also thought of using NSTextAttachments, but I wouldn’t like VoiceOver to
treat the characters as attachments (i.e. announcing their role and/or playing
the tone to report them).
Thanks in advance for your support!
Vincenzo
_______________________________________________
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