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

UI Automation in Windows Console: work around Microsoft bugs on Windows 10 version 1903 and improve caret movement #9773

Merged
merged 5 commits into from
Jun 21, 2019

Conversation

codeofdusk
Copy link
Contributor

@codeofdusk codeofdusk commented Jun 19, 2019

Link to issue number:

Closes #9632 and #9649. Builds on #9614. Incorporates #5991 with modifications.

Summary of the issue:

Currently:

  • On Windows 10 1903 and later, the collapse method on consoleUIATextInfo is broken, resulting in several caret and selection bugs.
  • In UIA controls, selection change events are not handled, reducing the accuracy of caret move detection.

Description of how this pull request fixes the issue:

  • Re-implements consoleUIATextInfo.collapse and consoleUIATextInfo._get_isCollapsed as suggested by @michaelDCurran.
  • Re-enables the caret event for UIA.
  • Adds a new _caretMovementTimeoutMultiplier variable to editable text objects, and sets it to 2 for UIA (some controls take a while to send events).

Testing performed:

Tested the console and Windows start menu search field on Windows 10 1903. Caret movement, selection, and backspace reporting are functional, even over ssh.

Known issues with pull request:

  • Occasionally in UIA consoles, the last character of the prompt is still read out when pressing backspace, especially if quickly deleting text. Can this be fixed?

Change log entry:

None

@LeonarddeR
Copy link
Collaborator

Does this partially implement #9660?

@codeofdusk
Copy link
Contributor Author

Does this partially implement #9660?

Yes – we now listen for caret events, but don't switch on auto select detection.

Copy link
Member

@michaelDCurran michaelDCurran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the Edge address bar, pressing backspace now fails to announce the deleted character.

  • Please move the __ne__ method onto ConsoleUIATextInfo
  • Please only multiply caretMovementTimeout on WinConsoleUIA NVDAObject.
    We do of course want to try and fix this for UIA in general at some point in the future, but due to the introduced bug, clearly for now this solution is only useful for consoles.

@codeofdusk
Copy link
Contributor Author

In the Edge address bar, pressing backspace now fails to announce the deleted character.

  • Please move the __ne__ method onto ConsoleUIATextInfo
  • Please only multiply caretMovementTimeout on WinConsoleUIA NVDAObject.
    We do of course want to try and fix this for UIA in general at some point in the future, but due to the introduced bug, clearly for now this solution is only useful for consoles.

@michaelDCurran Fixed.

@michaelDCurran michaelDCurran merged commit 27694a3 into nvaccess:master Jun 21, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jun 21, 2019
@codeofdusk codeofdusk mentioned this pull request Jun 21, 2019
michaelDCurran added a commit that referenced this pull request Jun 22, 2019
…on Windows 10 version 1903 and improve caret movement (#9773)"

This reverts commit 27694a3.
michaelDCurran added a commit that referenced this pull request Jun 22, 2019
…on Windows 10 version 1903 and improve caret movement (#9773)" (#9788)

This reverts commit 27694a3.
feerrenrut pushed a commit that referenced this pull request Jul 24, 2019
## Summary of the issue:

In text fields, when moving the caret with caret movement commands, such as the arrows, NVDA relies on bookmarks to find out whether the caret has moved.

In short:

1. You press left arrow
2. NVDA creates a bookmark of the current caret position
3. NVDA executes left arrow
4. For up to the caret movement timeout, NVDA tries to find out whether the caret has moved by creating new bookmarks and comparing them against the old.

However, for UIA, this comparison fails, as creating a bookmark at the end of a range and then removing one character from the end of the range results in a new bookmark that is equal to the former.

## Description of how this fixes the issue:

This PR introduces a different approach based on #9773. In first instance, this code caused #9786 to occur (i.e. editors in Chrome reporting the wrong caret position).

Compared to #9773, flow is now as follows:

-  In a loop in EditableText._hasCaretMoved, NVDA processes pedning events
-   If there is a focus event pending, the loop is exited
-   NVDA tries to find out whether the caret position has changed by creating a textInfo at the caret position
-   new code: only when this succeeds, NVDA checks for pending caret and textChange events. If the object that contains the caret has caretMovementDetectionUsesEvents set to False, it still ignores the caret events. This is what we do in IA2Web objects.

## Testing performed:

- Tested that deleted characters/words are again reported in UIA controls, such as MS Word
- Tested Notepad, Wordpad, Word Without UIA, Thunderbird, LibreOffice, start menu edit field, legacy command consoles and Skype Electron. Made sure that the caret was still correctly reported in all of them when moving with arrow keys or deleting.

## Known issues with pull request:

We can't set the caretMovementDetectionUsesEvents attribute to True on editableText.EditableText and then override it in other places, such as IA2Web. This is because EditableText precedes the IA2Web class as well as other classes in the mro Setting it on EditableText directly therefore makes it impossible for other classes to override the attribute. I solved this by making it a magic property on EditableText that first tries to call super before returning the default.

Fixes #9928
Follow up of  PR #9773
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UIA in Windows Console: Space Character is not Announced when Deleting Characters
4 participants