How do I specify values โ€‹โ€‹for the accessibility attribute for a menu item when using a custom view?

I am writing a custom view NSMenuItem

that I would like to make available. When I don't override accessibilityIsIgnored

(so the NSView

default is returned YES

), I can see in the Accessibility Inspector that there is a main object in the accessibility hierarchy AXMenuItem

for the menu item using a custom view, but the main part of the required attributes for the menu items , such as Title , is missing :

Screenshot of Accessibility Inspector locked on the AXMenuItem accessibility object, when ignoring accessibility

Required attributes are set for menu items that do not use a custom view.

When I override accessibilityIsIgnored

to return NO

then this results in an additional accessibility object being added to the hierarchy (object by default AXUnknown


Screenshot of Accessibility Inspector locked on the AXUnknown accessibility object under the AXMenuItem object, when not ignoring accessibility

The attribute values โ€‹โ€‹returned by the override accessibilityAttributeValue:

are applied to that object AXUnknown

underneath AXMenuItem

, not to the desired effect on the object itself AXMenuItem


How do I specify missing attribute values โ€‹โ€‹for a menu item?


source to share

All Articles