I have a button, that when pressed, shows a "helper" window.
This window is shown, but not given keyboard focus, via orderFrontRegardless
.
The window contains an NSTextView
with helper text inside.
For vision-impaired users, I would like OS X's voiceover to immediately read the contents of this window's text view when it appears.
I am attempting to make VoiceOver read the text via:
NSAccessibilityPostNotification(textView, NSAccessibilityValueChangedNotification);
In my subclass of NSTextView
I then override the accessibility method:
- (id)accessibilityAttributeValue:(NSString *)attribute
{
//The notification calls this method for attributes:
//AXRole: returns AXTextArea
//AXSharedCharacterRange: returns range of the text view
return [super accessibilityAttributeValue:attribute];
}
The notification causes it to query for AXRole
(NSAccessibilityRoleAttribute
) and AXSharedCharacterRange
(NSAccessibilitySharedCharacterRangeAttribute
).
The character range correctly returns the range of the text area.
However, at no point is AXValue
(NSAccessibilityValueAttribute
) requested. That is that I am expecting is required when wanting VoiceOver to read the textfield.
Why is the NSAccessibilityValueChangedNotification
not requesting the TextView's NSAccessibilityValueAttribute
? How do I make VoiceOver read the text area's text?
I believe there's no way you can do it without setting the focus to the desired NSTextView
.
I have found a solution using iOS that maybe can be implemented in this OSX application: VoiceOver: force an accessibility element to be selected after a screen transition
In iOS you can pass in an accessibility element when posting a
UIAccessibilityLayoutChangedNotification
orUIAccessibilityScreenChangedNotification
as the second argument toUIAccessibilityPostNotification
and VoiceOver will focus on that element.
Maybe you can use a similar approach with NSAccessibility
framework with NSAccessibilityPostNotification
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With