summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2022-11-07 12:45:09 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2022-11-11 10:21:32 +0000
commitb58876c296a5a87f50d5e554afc277e5bc752a16 (patch)
tree83234c8a32bd5fad2a684c47c935f78aaaba6ca5 /src
parentde16300661bc498eb02d8d5b36ccc07ebe595ca2 (diff)
Windows: Inform accessibility system about the focused child item
When a complex object (i.e. one with children that are themselves not fully exposed objects) gets focus, then we need to inform the accessibility system about which child object actually has focus. This was only done for item views, but not for other complex widgets. An editable QComboBoxes is the focus proxy for its line edit. The line edit never gets focus itself (QComboBox forwards relevant events), and is the accessible child item with index 1. So when an editable combobox gets focus, it needs to raise the automation event for the line edit child. Implement QAccessibleComboBox::focusChild to return the interface to the lineedit for editable comboboxes so that the UI Automation bridge can correctly notify about the focus being moved to an editable text input field. Fixes: QTBUG-107572 Pick-to: 6.4 6.2 Change-Id: Id60e2791ec859365255baa9bfd01547979cd2b44 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp5
-rw-r--r--src/widgets/accessible/complexwidgets.cpp10
-rw-r--r--src/widgets/accessible/complexwidgets_p.h1
3 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
index 03cac60e08..cb35ed398c 100644
--- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
+++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp
@@ -71,10 +71,11 @@ QWindowsUiaMainProvider::~QWindowsUiaMainProvider()
void QWindowsUiaMainProvider::notifyFocusChange(QAccessibleEvent *event)
{
if (QAccessibleInterface *accessible = event->accessibleInterface()) {
- // If this is a table/tree/list, raise event for the focused cell/item instead.
- if (accessible->tableInterface())
+ // If this is a complex element, raise event for the focused child instead.
+ if (accessible->childCount()) {
if (QAccessibleInterface *child = accessible->focusChild())
accessible = child;
+ }
if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible))
QWindowsUiaWrapper::instance()->raiseAutomationEvent(provider, UIA_AutomationFocusChangedEventId);
}
diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp
index ac8ec224b9..df81713d72 100644
--- a/src/widgets/accessible/complexwidgets.cpp
+++ b/src/widgets/accessible/complexwidgets.cpp
@@ -320,6 +320,16 @@ int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const
return -1;
}
+QAccessibleInterface *QAccessibleComboBox::focusChild() const
+{
+ // The editable combobox is the focus proxy of its lineedit, so the
+ // lineedit itself never gets focus. But it is the accessible focus
+ // child of an editable combobox.
+ if (comboBox()->isEditable())
+ return child(1);
+ return nullptr;
+}
+
/*! \reimp */
QString QAccessibleComboBox::text(QAccessible::Text t) const
{
diff --git a/src/widgets/accessible/complexwidgets_p.h b/src/widgets/accessible/complexwidgets_p.h
index 1fd5d5aeeb..12535f21a0 100644
--- a/src/widgets/accessible/complexwidgets_p.h
+++ b/src/widgets/accessible/complexwidgets_p.h
@@ -99,6 +99,7 @@ public:
QAccessibleInterface *childAt(int x, int y) const override;
int indexOfChild(const QAccessibleInterface *child) const override;
QAccessibleInterface* child(int index) const override;
+ QAccessibleInterface* focusChild() const override;
QString text(QAccessible::Text t) const override;