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.weghorn@posteo.de>
This commit is contained in:
parent
6974c10901
commit
eafef8fd19
2 changed files with 25 additions and 0 deletions
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue