vcl/source/treelist/svimpbox.cxx |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 6974c10901cc052bce23295ddff25530137e94c8
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Tue Oct 24 09:49:32 2023 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Tue Oct 24 12:57:32 2023 +0200

    tdf#135921 a11y: Toggle listbox item checkbox on space
    
    Allow toggling the state of the checkbox in a listbox/
    treelist entry using the space key if the entry is currently
    selected.
    
    This aligns it with the behavior for "plain" checkboxes.
    
    On the a11y layer, these listbox entries are
    even exposed just as a checkbox when there's only
    a single checkbox for the entry
    (s. `AccessibleListBoxEntry::getAccessibleRole`),
    like in the Spelling options dialog ("Tools" -> "Spelling",
    then press the "Options..." button).
    
    For the case where there are multiple checkboxes
    (like in the Writer autocorrect options dialog),
    the first checkbox will be toggled.
    Making it possible to toggle any of the checkboxes
    for that case would need further work, s.a. the
    the related tdf#135585.
    (For gtk3, it's possible to use the arrow keys
    to switch the column, then use the space key
    to toggle the checkbox.)
    That scenario also uses a different approach
    for the a11y layer, not a single
    `AccessibleListBoxEntry` object as is the case
    for the tdf#135921 scenario.
    
    This change makes it possible to toggle the checkbox,
    but so far, the new state is not yet announced
    when a screen reader is running, neither when
    using the keyboard nor when using the mouse
    (which was possible without this change already).
    The event handling that's required for this will
    be added in a separate commit.
    
    Change-Id: Ic78f9052d166be0da17a76261a09da02b8a11cd7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158374
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index f0fa1938a8a9..559882560a12 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -2326,13 +2326,24 @@ bool SvImpLBox::KeyInput( const KeyEvent& rKEvt)
                         // toggle selection
                         m_pView->Select( m_pCursor, !m_pView->IsSelected( 
m_pCursor ) );
                     }
-                    else if ( !m_pView->IsSelected( m_pCursor ) )
+                    else if (m_pView->IsSelected(m_pCursor))
+                    {
+                        // trigger button
+                        SvLBoxItem* pButtonItem = 
m_pCursor->GetFirstItem(SvLBoxItemType::Button);
+                        if (pButtonItem)
+                        {
+                            SvLBoxButton* pButton = 
static_cast<SvLBoxButton*>(pButtonItem);
+                            pButton->ClickHdl(m_pCursor);
+                            InvalidateEntry(m_pCursor);
+                        }
+                        else
+                            bKeyUsed = false;
+                    }
+                    else
                     {
                         SelAllDestrAnch( false );
                         m_pView->Select( m_pCursor );
                     }
-                    else
-                        bKeyUsed = false;
                 }
                 else
                     bKeyUsed = false;

Reply via email to