From b1e007f25eab20c1fc27d4ed23f80dd6f0e90c01 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Thu, 22 Apr 2021 09:01:09 +1000 Subject: [PATCH 1/2] Windows 10 Mail: ensure browse mode is used in the reading pane. --- source/appModules/hxmail.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/appModules/hxmail.py b/source/appModules/hxmail.py index e08e44bb3a6..0250aa42aaa 100644 --- a/source/appModules/hxmail.py +++ b/source/appModules/hxmail.py @@ -13,12 +13,26 @@ class MailWordDocumentTreeInterceptor(WordDocument.treeInterceptorClass): def _get_isAlive(self): - return super(MailWordDocumentTreeInterceptor,self).isAlive and self.rootNVDAObject.shouldCreateTreeInterceptor + return super().isAlive and self.rootNVDAObject.isInReadingPane + + def __init__(self, rootNVDAObject: "MailWordDocument"): + super().__init__(rootNVDAObject) + if rootNVDAObject.isInReadingPane: + # The base WordDocument TreeInterceptorClass forces focus mode by default + # As a TreeInterceptor is created for all word documents + # so that the NVDA elements list is available. + # However, Windows 10 Mail's reading pane should start in browse mode. + self.disableAutoPassThrough = False + self.passThrough = False class MailWordDocument(WordDocument): treeInterceptorClass=MailWordDocumentTreeInterceptor - def _get_shouldCreateTreeInterceptor(self): + + # typing information for isInReadingPane property + isInReadingPane: bool + + def _get_isInReadingPane(self) -> bool: # Locate the Reading pane in the ancestors condition=UIAHandler.handler.clientObject.createPropertyCondition(UIAHandler.UIA_ClassNamePropertyId,"ReadingPaneModern") walker=UIAHandler.handler.clientObject.createTreeWalker(condition) From 5e26200621e7e64e7f10625cc9785de1993020a0 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Thu, 22 Apr 2021 09:51:14 +1000 Subject: [PATCH 2/2] Windows 10 mail appModule: use event_treeInterceptor_gainFocus rather than the treeInterceptor's constructor to toggle browse mode. --- source/appModules/hxmail.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/source/appModules/hxmail.py b/source/appModules/hxmail.py index 0250aa42aaa..4036550dbd8 100644 --- a/source/appModules/hxmail.py +++ b/source/appModules/hxmail.py @@ -12,18 +12,23 @@ class MailWordDocumentTreeInterceptor(WordDocument.treeInterceptorClass): - def _get_isAlive(self): - return super().isAlive and self.rootNVDAObject.isInReadingPane + _wasInReadingPane: bool = False - def __init__(self, rootNVDAObject: "MailWordDocument"): - super().__init__(rootNVDAObject) - if rootNVDAObject.isInReadingPane: + def event_treeInterceptor_gainFocus(self): + isInReadingPane = self.rootNVDAObject.isInReadingPane + if isInReadingPane != self._wasInReadingPane: + self._wasInReadingPane = isInReadingPane # The base WordDocument TreeInterceptorClass forces focus mode by default # As a TreeInterceptor is created for all word documents # so that the NVDA elements list is available. - # However, Windows 10 Mail's reading pane should start in browse mode. - self.disableAutoPassThrough = False - self.passThrough = False + # However, Windows 10 Mail's reading pane should use browse mode. + if isInReadingPane: + self.disableAutoPassThrough = False + self.passThrough = False + else: + self.disableAutoPassThrough = True + self.passThrough = True + super().event_treeInterceptor_gainFocus() class MailWordDocument(WordDocument):