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>
This commit is contained in:
parent
f25804b395
commit
a149b3fd53
@ -3408,7 +3408,7 @@ void QListView::currentChanged(const QModelIndex ¤t, const QModelIndex &pr
|
||||
QAbstractItemView::currentChanged(current, previous);
|
||||
#if QT_CONFIG(accessibility)
|
||||
if (QAccessible::isActive()) {
|
||||
if (current.isValid()) {
|
||||
if (current.isValid() && hasFocus()) {
|
||||
int entry = visualIndex(current);
|
||||
QAccessibleEvent event(this, QAccessible::Focus);
|
||||
event.setChild(entry);
|
||||
|
@ -3494,7 +3494,7 @@ void QTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &p
|
||||
{
|
||||
#if QT_CONFIG(accessibility)
|
||||
if (QAccessible::isActive()) {
|
||||
if (current.isValid()) {
|
||||
if (current.isValid() && hasFocus()) {
|
||||
Q_D(QTableView);
|
||||
int entry = d->accessibleTable2Index(current);
|
||||
QAccessibleEvent event(this, QAccessible::Focus);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user