3

I have a NSTouchBar with an item whose view is a NSSegmentedControl that has 4 items - A, B, C, D. For a person with sight, it makes sense, but for a person who uses VoiceOver, just saying "A", "B", "C" or "D" isn't a great experience - they may not understand what exactly does that do, so I'd like to change the accessibility titles to "Select A", "Perform B", "Open C", "Show D".

AFAIK, the NSSegmentedControl doesn't have any methods on setting custom accessibility titles, so I've dug deeper - it seems that it creates a subview for each of the segments (NSSegmentItemView, but it's not important) - so I've tried:

  • setting the isAccessibilityElement to true on the segmented control itself
  • for each of the subviews, I've set it to true as well, and I've tried setting accessibility title, label, ... Pretty much anything that would help.

Unfortunately I can set anything I want on these and VoiceOver will ignore it. The issue is complicated by the fact that the Accessibility Inspector doesn't work on the Touch Bar window...

Does anyone have any ideas?

2 Answers 2

1

I was trying to do something similar (reimplement accessibility on a custom modification of NSSegmentedControl), and I was mostly successful by overriding some of NSAccessibilityProtocol methods.

In your case, you could try overriding accessibilityChildren to return custom elements that provide different labels.

1
  • Thanks, will try it! Definitely forgot about the option to override accessibility children! Nov 23, 2017 at 5:31
0

NSSegmentedControl will pick up the accessibilityDescription of the image. So the solution I used was to ensure all my segmented controls have images, and for each one, if necessary, make a copy of the image, set the accessibilityDescription explicitly, and reset the image. Some of my segments used single character text as well, so I created images of the characters instead and used them.

Ugly, but better than any other solution I found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.