From ff8958c346d02f5e9535fe633087734d7af63561 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Thu, 4 Jul 2024 12:04:31 +0200 Subject: [PATCH 1/2] Revert disabling handling of caret notifications for UIA --- source/NVDAObjects/UIA/__init__.py | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index fd9d4edcd9b..5db71848e5b 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -21,12 +21,12 @@ import numbers import colors import languageHandler +import NVDAState import UIAHandler import UIAHandler.customProps import UIAHandler.customAnnotations import controlTypes from controlTypes import TextPosition, TextAlign -import inputCore import config import speech import api @@ -2482,27 +2482,13 @@ def event_UIA_dropTargetEffect(self): ui.message(dropTargetEffect) -class InaccurateTextChangeEventEmittingEditableText(EditableTextBase, UIA): - # XAML and WPF fire UIA textSelectionChange events before the caret position change is reflected - # in the related UIA text pattern. - # This means that, apart from deleting text, NVDA cannot rely on textSelectionChange (caret) events - # in XAML or WPF to detect if the caret has moved, as it occurs too early. - caretMovementDetectionUsesEvents = False +if NVDAState._allowDeprecatedAPI(): - def _backspaceScriptHelper(self, unit: str, gesture: inputCore.InputGesture): - """As UIA text range objects from XAML or WPF don't mutate with backspace, - comparing a text range copied from before backspace with a text range fetched after backspace - isn't reliable, as the ranges compare equal. - Therefore, we must always rely on events for caret change detection in this case. - """ - self.caretMovementDetectionUsesEvents = True - try: - super()._backspaceScriptHelper(unit, gesture) - finally: - self.caretMovementDetectionUsesEvents = False + class InaccurateTextChangeEventEmittingEditableText(EditableTextBase, UIA): + """InaccurateTextChangeEventEmittingEditableText is deprecated without a replacement.""" -class XamlEditableText(InaccurateTextChangeEventEmittingEditableText): +class XamlEditableText(EditableTextBase, UIA): """An UIA element with editable text exposed by the XAML framework.""" ... @@ -2687,7 +2673,7 @@ class ToolTip(ToolTip, UIA): event_UIA_toolTipOpened = ToolTip.event_show -class WpfTextView(InaccurateTextChangeEventEmittingEditableText): +class WpfTextView(EditableTextBase, UIA): """WpfTextView fires name state changes once a second, plus when IUIAutomationTextRange::GetAttributeValue is called. This causes major lag when using this control with Braille in NVDA. (#2759) From b494491f75ec85cda8251c1f2b77e0a1719647d2 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Thu, 4 Jul 2024 12:27:01 +0200 Subject: [PATCH 2/2] Change log --- user_docs/en/changes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index ac7566c8276..39e09a7cbee 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -8,6 +8,8 @@ ### Bug Fixes +* NVDA once again relies on UIA events for caret movement in XAML and WPF text controls, rather than only on manual querying of the caret position. (#16817, @LeonarddeR) + ### Changes for Developers Please refer to [the developer guide](https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#API) for information on NVDA's API deprecation and removal process. @@ -16,6 +18,8 @@ Please refer to [the developer guide](https://www.nvaccess.org/files/nvda/docume #### Deprecations +* `NVDAObjects.UIA.InaccurateTextChangeEventEmittingEditableText` is deprecated with no replacement. (#16817, @LeonarddeR) + ## 2024.3 The Add-on Store will now notify you if any add-on updates are available on NVDA startup.