Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions source/appModules/hxmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,32 @@

class MailWordDocumentTreeInterceptor(WordDocument.treeInterceptorClass):

def _get_isAlive(self):
return super(MailWordDocumentTreeInterceptor,self).isAlive and self.rootNVDAObject.shouldCreateTreeInterceptor
_wasInReadingPane: bool = False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be initialized to False? Currently this will only be accurate after the gain focus event is fired the first time. Could this be initialized correctly in the __init__ method instead.

Could a situation arise where the object is created while focus is already in a readingpane? Thus no initial fire of the gainfocus to set this to True, but rendering it inaccurate?


def event_treeInterceptor_gainFocus(self):
isInReadingPane = self.rootNVDAObject.isInReadingPane

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that rootNVDAObject will always be a MailWordDocument. If I'm understanding this right, while unlikely, a developer may set this as the TreeInterceptor on a different object, resulting in it being constructed with a different type as the rootNVDAObject.

This took me quite some time to determine, typing would help, maybe something like this at class level:

rootNVDAObject: MailWordDocument

def __init__(self, obj:MailWordDocument):
		if not isinstance(obj, MailWordDocument):
				log.error("MailWordDocumentTreeInterceptor depends on rootNVDAObject being a MailWordDocument see event_treeInterceptor_gainFocus")
		super().__init(obj)

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