Skip to content

Commit ea84a19

Browse files
torarnvkeithel-qt
authored andcommitted
macOS: Activate Qt's platform a11y whenever the system queries us
Otherwise the cached information we store about e.g. table rows and columns will not be updated, as QAccessible::isActive() is false during QAbstractItemViewPrivate::rowsInserted(), and as a result we'll be operating on stale information when the system comes back later to query us about one of the cells. This was observed when running a Qt Widgets table app with the system's Keyboard Viewer open. Pick-to: 6.6 Change-Id: I88efd46dbc3d35c8b1888d3e29ef3d001bb9eac7 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> Cherry-picked into adsk-contrib-maya-v6.5.3 by Keith Kyzivat <keith.kyzivat@qt.io> on 20231102 to fix MAYA-131429. (cherry picked from commit cf13e4c)
1 parent b2e3164 commit ea84a19

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/plugins/platforms/cocoa/qnsview_accessibility.mm

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313

1414
@implementation QNSView (Accessibility)
1515

16+
- (void)activateQtAccessibility
17+
{
18+
// Activate the Qt accessibility machinery for all entry points
19+
// below that may be triggered by system accessibility queries,
20+
// as otherwise Qt is not aware that the system needs to know
21+
// about all accessibility state changes in Qt.
22+
QCocoaIntegration::instance()->accessibility()->setActive(true);
23+
}
24+
1625
- (id)childAccessibleElement
1726
{
1827
QCocoaWindow *platformWindow = self.platformWindow;
@@ -32,8 +41,7 @@ - (BOOL)accessibilityIsIgnored
3241

3342
- (id)accessibilityAttributeValue:(NSString *)attribute
3443
{
35-
// activate accessibility updates
36-
QCocoaIntegration::instance()->accessibility()->setActive(true);
44+
[self activateQtAccessibility];
3745

3846
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
3947
return NSAccessibilityUnignoredChildrenForOnlyChild([self childAccessibleElement]);
@@ -43,11 +51,13 @@ - (id)accessibilityAttributeValue:(NSString *)attribute
4351

4452
- (id)accessibilityHitTest:(NSPoint)point
4553
{
54+
[self activateQtAccessibility];
4655
return [[self childAccessibleElement] accessibilityHitTest:point];
4756
}
4857

4958
- (id)accessibilityFocusedUIElement
5059
{
60+
[self activateQtAccessibility];
5161
return [[self childAccessibleElement] accessibilityFocusedUIElement];
5262
}
5363

0 commit comments

Comments
 (0)