diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2023-11-04 22:55:03 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-12-12 00:44:31 +0000 |
commit | a149b3fd533525d0b260893019b41b300a554f8d (patch) | |
tree | a63fdf559ce4ccc640ab5c64bf8881185c76cd71 /src/widgets/itemviews/qtreeview.cpp | |
parent | f25804b3955d0b621ac8ff26470f950dbd1e3337 (diff) |
a11y: Only send focus event when item has focus
When the current item in an item view has changed,
only send an accessible focus event when the item view
actually has focus.
Sending a focus event when the item doesn't actually
have focus is incorrect and breaks focus tracking in
assistive technology, like the Orca screen reader.
With this change in place, the focus event for the
newly selected item/child still gets sent when
changing the item using the keyboard or
by clicking on it using the mouse (since the item
view has focus in those cases), but not
when it gets changed programmatically
while the keyboard focus is somewhere else.
Fixes: QTBUG-118800
Pick-to: 6.7 6.6 6.5
Change-Id: I5540cdfce6d0ed076d4bb871e5862fddcdf05941
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/itemviews/qtreeview.cpp')
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index c6ed979c13..de8f5ecdc9 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -4054,7 +4054,7 @@ void QTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &pr viewport()->update(d->visualRect(current, QTreeViewPrivate::FullRow)); } #if QT_CONFIG(accessibility) - if (QAccessible::isActive() && current.isValid()) { + if (QAccessible::isActive() && current.isValid() && hasFocus()) { Q_D(QTreeView); QAccessibleEvent event(this, QAccessible::Focus); |