Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable / hide accessibility element

I'm trying to hide several elements in my app from VoiceOver so that they don't get read aloud by the screen reader. On iOS, I'd set isAccessibilityElement to NO, but this has no effect on OSX. What's the correct way to go about hiding elements from VoiceOver?

For example, I have a series of labels contained inside a view that make no sense if they're spoken separately by VoiceOver. I'd like to set the accessibilityLabel on the container view to describe all the labels nested within. But if I do that, the labels inside are still read out by VoiceOver.

like image 577
bmueller Avatar asked Jul 20 '15 18:07

bmueller


People also ask

Does visibility hidden affect accessibility?

The main reason the visibility: hidden rule isn't just about visual visibility is because it affects the elements visibility to assistive technology as well. When we apply visibility: hidden to an element, it also removes it from the accessibility tree, which makes it invisible to technologies like screen readers.

How would you visually hide an element in the UI so it's still accessible for screen readers?

The conventional way is to use CSS ( display:none; and visibility:hidden; ) or the HTML 5 `hidden` attribute. These properties hide elements not only on the screen, but also for screen reader users. Thus, these elements will not be visible nor vocalized by Assistive technologies (AT).

How do I turn off swift accessibility?

Open your Android device's Settings app . Select Accessibility. Switch Access. At the top, select the On/Off switch.

How do I hide element from screen reader?

To hide text from a screen reader and display it visually, use the aria-hidden attribute and set it to true. To hide text from a screen reader and hide it visually use the hidden attribute. You can also use CSS to set display: none or visibility: hidden to hide an element from screen readers and visually.


1 Answers

In macOS, it is true that setting accessibilityElement to NO for NSButton, NSTextField and NSImageView has no effect. That is because these are controls – they inherit from NSControl. To make it work for controls, you must do it instead to the control's cell.

In an Objective-C project, I so subclassed several Cocoa controls. For example, whenever I want a image view to be skipped by VoiceOver, I set its Custom Class in Interface Builder to this:

/*!
 @brief    Image view which will be skipped over by VoiceOver

 @details  Be careful that you *really* want the view to be skipped over by
 VoiceOver, because its meaning is conveyed in a better, non-visual way,
 elsewhere.  Remember that not all VoiceOver users are completely blind.
  */
@interface SSYNoVoiceOverImageView : NSImageView {}
@end

@implementation SSYNoVoiceOverImageView

- (void)awakeFromNib {
    self.cell.accessibilityElement = NO;
}

@end
like image 99
Jerry Krinock Avatar answered Sep 17 '22 17:09

Jerry Krinock