accessibility/source/standard/vclxaccessiblelist.cxx | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-)
New commits: commit f6a6b1454c7c765c0fc2ef9dc3e6111509a88307 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu Sep 7 14:08:57 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Sep 7 21:02:48 2023 +0200 tdf#157137 a11y: Don't report active descendant when not focused Since an active descendant is the UI element with keyboard focus, only send an `ACTIVE_DESCENDANT_CHANGED` event in `VCLXAccessibleList` if the listbox/combobox actually has focus, not when the selection changed otherwise, e.g. because the value was changed programmatically because it depends on another UI control (like the paper size in the print dialog depends on the selected printer. Change-Id: I008e742ccf3b81c70832707b2f3a6551827a0706 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156666 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx index 67061aac3ab0..62ac35a82aff 100644 --- a/accessibility/source/standard/vclxaccessiblelist.cxx +++ b/accessibility/source/standard/vclxaccessiblelist.cxx @@ -251,6 +251,12 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList) } } + // since an active descendant is the UI element with keyboard focus, only send + // ACTIVE_DESCENDANT_CHANGED if the listbox/combobox has focus + vcl::Window* pWindow = GetWindow(); + assert(pWindow); + const bool bFocused = pWindow->HasChildPathFocus(); + if (m_aBoxType == COMBOBOX) { //VCLXAccessibleDropDownComboBox @@ -259,10 +265,13 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList) { if ( aNewValue.hasValue() || aOldValue.hasValue() ) { - NotifyAccessibleEvent( - AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, - aOldValue, - aNewValue ); + if (bFocused) + { + NotifyAccessibleEvent( + AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, + aOldValue, + aNewValue ); + } NotifyListItem(aNewValue); } @@ -277,10 +286,13 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList) { if ( aNewValue.hasValue() || aOldValue.hasValue() ) { - NotifyAccessibleEvent( - AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, - aOldValue, - aNewValue ); + if (bFocused) + { + NotifyAccessibleEvent( + AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, + aOldValue, + aNewValue ); + } NotifyListItem(aNewValue); }