From aa920e627497f9f079e956132bcebc8eadddf3fd Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 23 Apr 2014 13:27:55 +0200 Subject: [PATCH] Accessibility Windows: Improve Menus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This would especially trigger when moving the focus between menus - after the right menu got the focus we would send another event for the QMenuBar, preventing the screen reader from reading the actually selected menu, announcing the menu bar instead. [ChangeLog][QtWidgets][QMenu] Accessibility: Menus are read by screen readers with more reliability. Task-number: QTBUG-38498 Change-Id: Ie4028120b234949380315296bf07ca53863d0ad8 Reviewed-by: Jan Arve Sæther --- src/widgets/kernel/qwidget.cpp | 2 -- src/widgets/widgets/qmenu.cpp | 3 --- src/widgets/widgets/qmenubar.cpp | 3 --- 3 files changed, 8 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index f79eaf197d..65e435fbdc 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -6002,10 +6002,8 @@ void QWidget::setFocus(Qt::FocusReason reason) if (!(testAttribute(Qt::WA_WState_Created) && window()->windowType() != Qt::Popup && internalWinId())) //setFocusWidget will already post a focus event for us (that the AT client receives) on Windows # endif -# ifdef Q_OS_UNIX // menus update the focus manually and this would create bogus events if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) -# endif { QAccessibleEvent event(f, QAccessible::Focus); QAccessible::updateAccessibility(&event); diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index eb93e461c0..4cf39b3bb5 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1091,9 +1091,6 @@ void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e QAccessibleEvent focusEvent(q, QAccessible::Focus); focusEvent.setChild(actionIndex); QAccessible::updateAccessibility(&focusEvent); - QAccessibleEvent selectionEvent(q, QAccessible::Selection); - focusEvent.setChild(actionIndex); - QAccessible::updateAccessibility(&selectionEvent); } #endif action->showStatusText(topCausedWidget()); diff --git a/src/widgets/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp index 03ab490823..729e08c7a5 100644 --- a/src/widgets/widgets/qmenubar.cpp +++ b/src/widgets/widgets/qmenubar.cpp @@ -531,9 +531,6 @@ void QMenuBarPrivate::_q_actionHovered() QAccessibleEvent focusEvent(q, QAccessible::Focus); focusEvent.setChild(actionIndex); QAccessible::updateAccessibility(&focusEvent); - QAccessibleEvent selectionEvent(q, QAccessible::Selection); - selectionEvent.setChild(actionIndex); - QAccessible::updateAccessibility(&selectionEvent); } #endif //QT_NO_ACCESSIBILITY }