Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert disabling handling of caret notifications for UIA #16817

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""

...
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down