Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qiosplatformaccessibility.mm
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
5
7
8#if QT_CONFIG(accessibility)
9
10#include <QtGui/QtGui>
11#include "qioswindow.h"
13
14QIOSPlatformAccessibility::QIOSPlatformAccessibility()
15{}
16
17QIOSPlatformAccessibility::~QIOSPlatformAccessibility()
18{}
19
20
21void invalidateCache(QAccessibleInterface *iface)
22{
23 if (!iface || !iface->isValid()) {
24 qWarning() << "invalid accessible interface: " << iface;
25 return;
26 }
27
28 // This will invalidate everything regardless of what window the
29 // interface belonged to. We might want to revisit this strategy later.
30 // (Therefore this function still takes the interface as argument)
32 if (win && win->handle()) {
33 QT_PREPEND_NAMESPACE(QIOSWindow) *window = static_cast<QT_PREPEND_NAMESPACE(QIOSWindow) *>(win->handle());
34 window->clearAccessibleCache();
35 }
36 }
37}
38
39
40void QIOSPlatformAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event)
41{
42 auto *accessibleInterface = event->accessibleInterface();
43 if (!isActive() || !accessibleInterface)
44 return;
45 switch (event->type()) {
46 case QAccessible::Focus: {
47 auto *element = [QMacAccessibilityElement elementWithId:event->uniqueId()];
48 Q_ASSERT(element);
49 // There's no NSAccessibilityFocusedUIElementChangedNotification, like we have on
50 // macOS. Instead, the documentation for UIAccessibilityLayoutChangedNotification
51 // specifies that the optional argument to UIAccessibilityPostNotification is the
52 // accessibility element for VoiceOver to move to after processing the notification.
53 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, element);
54 break;
55 }
56 case QAccessible::ObjectCreated:
57 case QAccessible::ObjectShow:
58 case QAccessible::ObjectHide:
59 case QAccessible::ObjectDestroyed:
60 invalidateCache(accessibleInterface);
61 switch (accessibleInterface->role()) {
62 case QAccessible::Window:
63 case QAccessible::Dialog:
64 // Bigger changes to the UI require a full reset of VoiceOver
65 UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
66 break;
67 default:
68 // While smaller changes can be handled by re-reading the layout
69 UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
70 }
71 break;
72 default:
73 break;
74 }
75}
76
77#endif
bool isActive
static QWindowList topLevelWindows()
Returns a list of the top-level windows in the application.
\inmodule QtGui
Definition qwindow.h:63
constexpr QBindableInterface iface
Definition qproperty.h:666
#define qWarning
Definition qlogging.h:166
struct _cl_event * event
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QWidget * win
Definition settings.cpp:6
aWidget window() -> setWindowTitle("New Window Title")
[2]