accessibility/source/extended/accessiblelistboxentry.cxx |   17 +++++++++++++++
 vcl/source/treelist/svimpbox.cxx                         |    8 +++++++
 2 files changed, 25 insertions(+)

New commits:
commit eafef8fd195654f0e7dbd007bcc7fa0f6d29b599
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Oct 24 10:03:44 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Oct 24 12:58:14 2023 +0200

    tdf#135921 a11y Send event when toggling listbox checkbox
    
    When toggling the state of the checkbox in a listbox/
    treelist entry using the mouse or the keyboard, emit
    a `VclEventId::CheckboxToggle` event and process
    that in the a11y class that's used for the case
    where there's just a single checkbox (like in the
    spelling options dialog), `AccessibleListBoxEntry`
    by sending a corresponding STATE_CHANGED event
    on the a11y layer.
    
    This makes Orca with the qt6 VCL plugin and NVDA on Windows
    announce the new value when toggling a checkbox in the
    Spelling options dialog using either the mouse or the
    keyboard.
    
    As mentioned in the previous commit,
    
       Change-Id Ic78f9052d166be0da17a76261a09da02b8a11cd7
       tdf#135921 a11y: Toggle listbox item checkbox on space
    
    , the case where a listbox entry has multiple checkboxes
    (like the autocorrect options dialog in Writer)
    uses different a11y classes and toggling a checkbox there
    still doesn't result in the new value being announced.
    
    Change-Id: I36a2b0a3fa3154279fb06af023fdb96f699fac2f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158375
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx 
b/accessibility/source/extended/accessiblelistboxentry.cxx
index 69feac418805..10433d882730 100644
--- a/accessibility/source/extended/accessiblelistboxentry.cxx
+++ b/accessibility/source/extended/accessiblelistboxentry.cxx
@@ -23,6 +23,7 @@
 #include <svtools/stringtransfer.hxx>
 #include <vcl/toolkit/svlbitm.hxx>
 #include <com/sun/star/awt/Rectangle.hpp>
+#include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -84,6 +85,22 @@ namespace accessibility
 
         switch ( rEvent.GetId() )
         {
+            case VclEventId::CheckboxToggle:
+            {
+                // assert this object is represented as a checkbox on a11y 
layer (LABEL role is used for
+                // SvButtonState::Tristate, s. 
AccessibleListBoxEntry::getAccessibleRole)
+                assert(getAccessibleRole() == AccessibleRole::CHECK_BOX
+                       || getAccessibleRole() == AccessibleRole::LABEL);
+                Any aOldValue;
+                Any aNewValue;
+                if (getAccessibleStateSet() & AccessibleStateType::CHECKED)
+                    aNewValue <<= AccessibleStateType::CHECKED;
+                else
+                    aOldValue <<= AccessibleStateType::CHECKED;
+
+                NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, 
aOldValue, aNewValue);
+                break;
+            }
             case  VclEventId::ObjectDying :
             {
                 if ( m_pTreeListBox )
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index 559882560a12..0deea8f69820 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -1849,7 +1849,12 @@ bool SvImpLBox::ButtonUpCheckCtrl( const MouseEvent& 
rMEvt )
         m_pActiveButton->SetStateHilighted( false );
         tools::Long nMouseX = rMEvt.GetPosPixel().X();
         if (pEntry == m_pActiveEntry && m_pView->GetItem(m_pActiveEntry, 
nMouseX) == m_pActiveButton)
+        {
+            const bool bChecked = m_pActiveButton->IsStateChecked();
             m_pActiveButton->ClickHdl(m_pActiveEntry);
+            if (m_pActiveButton->IsStateChecked() != bChecked)
+                CallEventListeners(VclEventId::CheckboxToggle, m_pActiveEntry);
+        }
         InvalidateEntry(m_pActiveEntry);
         if (m_pCursor == m_pActiveEntry)
             ShowCursor(true);
@@ -2333,8 +2338,11 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
                         if (pButtonItem)
                         {
                             SvLBoxButton* pButton = 
static_cast<SvLBoxButton*>(pButtonItem);
+                            const bool bChecked = pButton->IsStateChecked();
                             pButton->ClickHdl(m_pCursor);
                             InvalidateEntry(m_pCursor);
+                            if (pButton->IsStateChecked() != bChecked)
+                                CallEventListeners(VclEventId::CheckboxToggle, 
m_pActiveEntry);
                         }
                         else
                             bKeyUsed = false;

Reply via email to