0

I am using hidden NSButtons in my OS X app to provide keyboard shortcuts. How can I hide these views from the accessibility tree? I have tried this:

button.accessibilityElement = NO;
button.accessibilityEnabled = NO;
button.accessibilityLabel = @"Test";

VoiceOver will read "test" so it is clearly using the properties I am setting. When I set accessibilityEnabled to NO, it reads out "dimmed" as well for each button.

How can I get VoiceOver to completely ignore these views?

RealCasually
  • 3,593
  • 3
  • 27
  • 34
  • Curious why the downvotes. If you are downvoting, I'd love to see what you think I'm missing. – RealCasually Mar 30 '16 at 23:10
  • 1
    Instead of using a hidden UI element to respond to a keyboard shortcut, you should really be using a menu item. Is there some reason you can't do that instead? Your current approach doesn't feel very clean. – Nick K9 Apr 21 '16 at 10:56
  • I do think you are right, I'll give this a shot. – RealCasually Apr 21 '16 at 18:28

1 Answers1

1

Have you tried setting the button to hidden? If you set the view to be hidden, it won’t participate in the accessibility tree, but it will still accept keyboard shortcut events.

button.hidden = YES;