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 0f7c141 commit c21af0a
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 @@ -16,6 +16,7 @@
from winVersion import isAtLeastWin10
from . import UIATextInfo
from ..behaviors import Terminal
from ..window import Window


class consoleUIATextInfo(UIATextInfo):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c21af0a

Please sign in to comment.