Skip to content

Commit

Permalink
Add focus redirection for the UIA console main window.
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofdusk committed Jun 5, 2019
1 parent 4ff3172 commit 5a824fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 6 additions & 3 deletions source/NVDAObjects/UIA/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,14 @@ 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)
if self.UIAElement.cachedAutomationId == "Text Area":
from .winConsoleUIA import winConsoleUIA
clsList.append(winConsoleUIA)
if self.UIAElement.cachedAutomationId == "Console Window":
from .winConsoleUIA import consoleUIAWindow
clsList.append(consoleUIAWindow)
# Add editableText support if UIA supports a text pattern
if self.TextInfo==UIATextInfo:
clsList.append(EditableTextWithoutAutoSelectDetection)
Expand Down
15 changes: 15 additions & 0 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from winVersion import isAtLeastWin10
from . import UIATextInfo
from ..behaviors import Terminal
from ..window import Window


class consoleUIATextInfo(UIATextInfo):
Expand All @@ -33,6 +34,20 @@ def __init__(self, obj, position, _rangeObj=None):
)


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
Expand Down

0 comments on commit 5a824fb

Please sign in to comment.