Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.4
-
None
Description
Some properties that are exposed through QMacAccessibilityElement are only relevant for certain element types/roles, but they are exposed regardless. You can see this by using Accessibility Inspector on a QSlider vs using it on a macOS slider and compare the difference. Attached is the screenshot of Accessibility Inspector for Screenshot macOS Slider.png and Screenshot QSlider.png
. (Notice that QSlider has some cruft that only makes sense to text elements). Currently, the properties that are affected by this is:
- accessibilityNumberOfCharacters
- accessibilityVisibleCharacterRange
- accessibilityInsertionPointLineNumber
- accessibilitySelectedText
- accessibilitySelectedTextRange
This list will expand as we implement more specialized behavior (e.g. the table type will probably need to implement accessibilityRows, accessibilityColumns and accessibilityIndex, which are irrelevant for e.g. a slider).
It turns out that this can be controlled by implementing
isAccessibilitySelectorAllowed
For reference, this is a simple implementation on how a basic implementation can be:
- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); if (iface && iface->isValid()) { if (!iface->textInterface() && (selector == @selector(accessibilityNumberOfCharacters) || selector == @selector(accessibilityVisibleCharacterRange) || selector == @selector(accessibilityInsertionPointLineNumber) || selector == @selector(accessibilitySelectedText) || selector == @selector(accessibilitySelectedTextRange))) { return false; } } return true; }