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. Change-Id: I88efd46dbc3d35c8b1888d3e29ef3d001bb9eac7 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io> (cherry picked from commit cf13e4c84c44b6f66f651035b3c3d012718b82dc) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
6818d6915d
commit
e58b1efcae
@ -13,6 +13,15 @@
|
|||||||
|
|
||||||
@implementation QNSView (Accessibility)
|
@implementation QNSView (Accessibility)
|
||||||
|
|
||||||
|
- (void)activateQtAccessibility
|
||||||
|
{
|
||||||
|
// Activate the Qt accessibility machinery for all entry points
|
||||||
|
// below that may be triggered by system accessibility queries,
|
||||||
|
// as otherwise Qt is not aware that the system needs to know
|
||||||
|
// about all accessibility state changes in Qt.
|
||||||
|
QCocoaIntegration::instance()->accessibility()->setActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
- (id)childAccessibleElement
|
- (id)childAccessibleElement
|
||||||
{
|
{
|
||||||
QCocoaWindow *platformWindow = self.platformWindow;
|
QCocoaWindow *platformWindow = self.platformWindow;
|
||||||
@ -32,8 +41,7 @@
|
|||||||
|
|
||||||
- (id)accessibilityAttributeValue:(NSString *)attribute
|
- (id)accessibilityAttributeValue:(NSString *)attribute
|
||||||
{
|
{
|
||||||
// activate accessibility updates
|
[self activateQtAccessibility];
|
||||||
QCocoaIntegration::instance()->accessibility()->setActive(true);
|
|
||||||
|
|
||||||
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
|
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
|
||||||
return NSAccessibilityUnignoredChildrenForOnlyChild([self childAccessibleElement]);
|
return NSAccessibilityUnignoredChildrenForOnlyChild([self childAccessibleElement]);
|
||||||
@ -43,11 +51,13 @@
|
|||||||
|
|
||||||
- (id)accessibilityHitTest:(NSPoint)point
|
- (id)accessibilityHitTest:(NSPoint)point
|
||||||
{
|
{
|
||||||
|
[self activateQtAccessibility];
|
||||||
return [[self childAccessibleElement] accessibilityHitTest:point];
|
return [[self childAccessibleElement] accessibilityHitTest:point];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)accessibilityFocusedUIElement
|
- (id)accessibilityFocusedUIElement
|
||||||
{
|
{
|
||||||
|
[self activateQtAccessibility];
|
||||||
return [[self childAccessibleElement] accessibilityFocusedUIElement];
|
return [[self childAccessibleElement] accessibilityFocusedUIElement];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user