accessibility/source/standard/vclxaccessiblebutton.cxx |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

New commits:
commit 97c9b0ccedeecf37c565adffb9f3823558013848
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Thu Nov 2 13:28:22 2023 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Nov 2 15:54:24 2023 +0100

    tdf#112661 tdf#112662 a11y: Fix toggling button via a11y action
    
    `PushButton::Click does not` toggle a `PushButton`
    that is a toggle button. Therefore, call
    `PushButton::Check` and `PushButton::Toggle` instead
    when the acessible "press" action is performed on
    a toggle button, which makes this work as expected.
    
    The same is already done in the UITest code, see
    `ButtonUIObject::execute`.
    
    The originally rerported issue in tdf#112661 and
    tdf#112662 was that there was no action available
    for the "Templates" and "Recent Documents" toggle
    buttons in the start center via the NSAccessibility
    API on macOS at all. By now, the "press" action was
    available, but performing the action (e.g. using
    the Ctrl+CapsLock+Space keyboard shortcut for
    VoiceOver) didn't have any effect.
    The same was true when performing the action via
    Accerciser using the AT-SPI Action interface when
    using the qt6 VCL plugin on Linux.
    
    With this change in place, toggling between
    showing the templates and the recently used
    documents in the start center works using that
    action, just as it does when clicking on one
    of the toggle buttons in the UI using the mouse.
    
    For gtk3, which is using native GtkToggleButtons,
    this was already working without this change in place.
    
    Change-Id: Ie3f02ec914239e0718ca1bfb4ba701f0831bb16a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158807
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/accessibility/source/standard/vclxaccessiblebutton.cxx 
b/accessibility/source/standard/vclxaccessiblebutton.cxx
index 52153a0c22b9..31c8188b99ab 100644
--- a/accessibility/source/standard/vclxaccessiblebutton.cxx
+++ b/accessibility/source/standard/vclxaccessiblebutton.cxx
@@ -167,7 +167,18 @@ sal_Bool VCLXAccessibleButton::doAccessibleAction ( 
sal_Int32 nIndex )
 
     VclPtr< PushButton > pButton = GetAs< PushButton >();
     if ( pButton )
-        pButton->Click();
+    {
+        if (pButton->isToggleButton())
+        {
+            // PushButton::Click doesn't toggle when it's a toggle button
+            pButton->Check(!pButton->IsChecked());
+            pButton->Toggle();
+        }
+        else
+        {
+            pButton->Click();
+        }
+    }
 
     return true;
 }

Reply via email to