V2 of UI Automation in Windows Console: work around Microsoft bugs on Windows 10 version 1903 and improve caret movement#9802
Conversation
LeonarddeR
left a comment
There was a problem hiding this comment.
I've hade some nights sleep about this.
While it caused issues, I really liked the idea that editableText._hasCaretMoved processed caret events. How about something like this (would be good to know @michaelDCurran's pinion before starting on this).
- Below the
Caret events are unreliable in some controls.comment, add something like this:
if self.detectCaretMovementUsingEvents and eventHandler.isPendingEvents("caret"):
log.debug("Caret move detected using event. Elapsed: %d ms" % elapsed)
return (True, newInfo)
Then, detectCaretMovementUsingEvents should be False by default, and only set to True for implementations where we are really sure that the textInfo doesn't lag behind.
| ) | ||
|
|
||
| def __ne__(self,other): | ||
| """Support more accurate caret move detection.""" |
There was a problem hiding this comment.
How does ne relate to caret move detection?
There was a problem hiding this comment.
Can you explain exactly what happens if you don't implement this method?
There was a problem hiding this comment.
__ne__ is necessary as UIATextInfo has overridden __eq__```. So we want ```__ne__``` to return the opposite. This should really actually be on UIATextInfo itself, but this has caused strange bugs in the past, espcially in Edge. We are not sure why IUIAutomationTextRange.compare does not work correctly for some implementations. In consoles however, it does work okay. Note that in Python3 it will no longer be neceesary to provide a ```__ne__``` here as Python3 automatically implements ```__ne__ as the negative of __eq__.
| ) | ||
|
|
||
| def __ne__(self,other): | ||
| """Support more accurate caret move detection.""" |
There was a problem hiding this comment.
Can you explain exactly what happens if you don't implement this method?
|
Link to issue number:
Closes #9632 and #9649. Builds on #9614. Incorporates the
__ne__method from #5991 for UIA consoletextInfos.Summary of the issue:
Currently:
collapsemethod onconsoleUIATextInfois broken, resulting in several caret and selection bugs.Description of how this pull request fixes the issue:
consoleUIATextInfo.collapseandconsoleUIATextInfo._get_isCollapsedas suggested by @michaelDCurran.__ne__method toconsoleUIATextInfoto allow for better caret move detection._caretMovementTimeoutMultipliervariable to editable text objects, and sets it to 1.5 for consoles (caret movement oversshcan be slowe).Note: unlike #9773, this PR does not depend on
caretevents (which caused #9786).Testing performed:
Tested the console on Windows 10 1903. Caret movement, selection, and backspace reporting are functional, even over
ssh.Known issues with pull request:
Change log entry:
None.