accessibility/source/standard/vclxaccessiblecheckbox.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit f60072a76730194acab1c5103812f0d2e3271d18
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Fri Oct 11 22:07:13 2024 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Sat Oct 12 17:18:42 2024 +0200

    a11y: Send value change event when checkbox value changes
    
    VCLXAccessibleCheckBox implements XAccessibleValue. The value
    returned by VCLXAccessibleCheckBox::getCurrentValue is based
    on the current checkbox state and is 0 if the checkbox is
    unchecked, 1 when it's checked, and 2 when it's indeterminate.
    
    Therefore, also send a VALUE_CHANGED event when the value changes,
    not just STATE_CHANGED events for the CHECKED and/or INDETERMINATE
    states.
    
    With this in place, changing the state of a checkbox (e.g.
    in the "Tools" -> "Options" dialog) now causes the value displayed
    in Accerciser's "Interface Viewer", section "Value" to be updated
    right away when a checkbox is (un)checked when using the qt6 VCL
    plugin, just as is the case for the "checked" state in the
    "Accessible" section in Accerciser.
    (Previously, the new value would only be shown after temporarily
    selecting another object in the a11y tree, then selecting the
    checkbox object again.)
    
    Change-Id: I1a7da3b15a18beb12637a632c1779601ad1f198d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174829
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/accessibility/source/standard/vclxaccessiblecheckbox.cxx 
b/accessibility/source/standard/vclxaccessiblecheckbox.cxx
index 018878714e8a..46c3e8749e92 100644
--- a/accessibility/source/standard/vclxaccessiblecheckbox.cxx
+++ b/accessibility/source/standard/vclxaccessiblecheckbox.cxx
@@ -112,8 +112,14 @@ void VCLXAccessibleCheckBox::ProcessWindowEvent( const 
VclWindowEvent& rVclWindo
     {
         case VclEventId::CheckboxToggle:
         {
+            const sal_Int32 nOldValue = m_bIndeterminate ? 2 : (m_bChecked ? 1 
: 0);
+
             SetChecked( IsChecked() );
             SetIndeterminate( IsIndeterminate() );
+
+            const sal_Int32 nNewValue = m_bIndeterminate ? 2 : (m_bChecked ? 1 
: 0);
+            if (nOldValue != nNewValue)
+                NotifyAccessibleEvent(AccessibleEventId::VALUE_CHANGED, 
Any(nOldValue), Any(nNewValue));
         }
         break;
         default:

Reply via email to