Skip to content
Permalink
Browse files

UI Automation in Windows Console: add focus redirection for the UIA c…

…onsole main window (#9674)

* Add focus redirection for the UIA console main window.

* Implement winConsoleUIA.findExtraOverlayClasses.

* If->elif
  • Loading branch information...
codeofdusk authored and michaelDCurran committed Jun 11, 2019
1 parent 549a6aa commit 11ec1be097e07445b1cd0ae1bda0ca78ecfe7d9b
Showing with 23 additions and 3 deletions.
  1. +2 −3 source/NVDAObjects/UIA/__init__.py
  2. +21 −0 source/NVDAObjects/UIA/winConsoleUIA.py
@@ -861,11 +861,10 @@ def findOverlayClasses(self,clsList):
# Support Windows Console's UIA interface
if (
self.windowClassName == "ConsoleWindowClass"
and self.UIAElement.cachedAutomationId == "Text Area"
and config.conf['UIA']['winConsoleImplementation'] == "UIA"
):
from .winConsoleUIA import winConsoleUIA
clsList.append(winConsoleUIA)
from . import winConsoleUIA
winConsoleUIA.findExtraOverlayClasses(self, clsList)
# Add editableText support if UIA supports a text pattern
if self.TextInfo==UIATextInfo:
clsList.append(EditableTextWithoutAutoSelectDetection)
@@ -16,6 +16,7 @@
from winVersion import isAtLeastWin10
from . import UIATextInfo
from ..behaviors import Terminal
from ..window import Window


class consoleUIATextInfo(UIATextInfo):
@@ -183,6 +184,20 @@ def _getWordOffsetsInThisLine(self, offset, lineInfo):
)


class consoleUIAWindow(Window):
def _get_focusRedirect(self):
"""
Sometimes, attempting to interact with the console too quickly after
focusing the window can make NVDA unable to get any caret or review
information or receive new text events.
To work around this, we must redirect focus to the console text area.
"""
for child in self.children:
if isinstance(child, winConsoleUIA):
return child
return None


class winConsoleUIA(Terminal):
STABILIZE_DELAY = 0.03
_TextInfo = consoleUIATextInfo
@@ -243,3 +258,9 @@ def _getTextLines(self):
ptr = self.UIATextPattern.GetVisibleRanges()
res = [ptr.GetElement(i).GetText(-1) for i in range(ptr.length)]
return res

def findExtraOverlayClasses(obj, clsList):
if obj.UIAElement.cachedAutomationId == "Text Area":
clsList.append(winConsoleUIA)
elif obj.UIAElement.cachedAutomationId == "Console Window":
clsList.append(consoleUIAWindow)

0 comments on commit 11ec1be

Please sign in to comment.
You can’t perform that action at this time.