accessibility/inc/standard/vclxaccessibletextcomponent.hxx | 3 +++ accessibility/source/standard/vclxaccessibletextcomponent.cxx | 8 ++++++++ 2 files changed, 11 insertions(+)
New commits: commit a5593114bb409c93c7cf79a3abac0c60a8aebb18 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Fri Sep 1 13:48:50 2023 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri Sep 1 16:13:40 2023 +0200 tdf#104833 a11y Send name changed event for text controls The text is at least often used for the accessible name of text controls (e.g. the MultiLineEdit case in tdf#104833). Therefore, also check whether the a11y name has changed from the previously remembered one in `VCLXAccessibleTextComponent::SetText` and send a NAME_CHANGED event if it has. This e.g. makes sure that the a11y name for the multi line edit in the update dialog is updated on Windows and NVDA properly announces it when it receives focus. (It now correctly announces "LibreOfficeDev 24.2 is up to date." instead of the obsolete cached name "Checking..."). Also see how `VCLXAccessibleTextComponent::ProcessWindowEvent` calls `VCLXAccessibleTextComponent::SetText` when processing `VclEventId::WindowFrameTitleChanged` and this comment in `Window::SetText` mentions that `VclEventId::WindowFrameTitleChanged` is used to notify about a11y name changes: // #107247# needed for accessibility // The VclEventId::WindowFrameTitleChanged is (mis)used to notify accessible name changes. // Therefore a window, which is labeled by this window, must also notify an accessible // name change. Change-Id: I2f15fe78324b14c3bbeae943cb87384007e21618 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156411 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/accessibility/inc/standard/vclxaccessibletextcomponent.hxx b/accessibility/inc/standard/vclxaccessibletextcomponent.hxx index cb2e20694663..3585dd778574 100644 --- a/accessibility/inc/standard/vclxaccessibletextcomponent.hxx +++ b/accessibility/inc/standard/vclxaccessibletextcomponent.hxx @@ -34,6 +34,9 @@ class VCLXAccessibleTextComponent : public cppu::ImplInheritanceHelper< { OUString m_sText; + // accessible name the object had when SetText was called last time + OUString m_sOldName; + protected: void SetText( const OUString& sText ); diff --git a/accessibility/source/standard/vclxaccessibletextcomponent.cxx b/accessibility/source/standard/vclxaccessibletextcomponent.cxx index ef3cbed4b1ec..f876f0b9ed38 100644 --- a/accessibility/source/standard/vclxaccessibletextcomponent.cxx +++ b/accessibility/source/standard/vclxaccessibletextcomponent.cxx @@ -61,6 +61,14 @@ void VCLXAccessibleTextComponent::SetText( const OUString& sText ) m_sText = sText; NotifyAccessibleEvent( AccessibleEventId::TEXT_CHANGED, aOldValue, aNewValue ); } + + // check whether accessible name has also changed, since text is (often) used as name as well + const OUString sName = getAccessibleName(); + if (sName != m_sOldName) + { + NotifyAccessibleEvent(AccessibleEventId::NAME_CHANGED, Any(m_sOldName), Any(sName)); + m_sOldName = sName; + } }