diff --git a/source/appModules/hxmail.py b/source/appModules/hxmail.py index e08e44bb3a6..4036550dbd8 100644 --- a/source/appModules/hxmail.py +++ b/source/appModules/hxmail.py @@ -12,13 +12,32 @@ class MailWordDocumentTreeInterceptor(WordDocument.treeInterceptorClass): - def _get_isAlive(self): - return super(MailWordDocumentTreeInterceptor,self).isAlive and self.rootNVDAObject.shouldCreateTreeInterceptor + _wasInReadingPane: bool = False + + 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 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): 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)