Skip to content

Commit 223e0f7

Browse files
Merge c15c1bf into 4a8593d
2 parents 4a8593d + c15c1bf commit 223e0f7

3 files changed

Lines changed: 19 additions & 9 deletions

File tree

source/NVDAObjects/UIA/wordDocument.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ def getTextWithFields(self,formatConfig=None):
329329

330330
class WordBrowseModeDocument(UIABrowseModeDocument):
331331

332+
def scrollToPosition(self, info: UIATextInfo):
333+
info._rangeObj.scrollIntoView(True)
334+
332335
def shouldSetFocusToObj(self,obj):
333336
# Ignore strange editable text fields surrounding most inner fields (links, table cells etc)
334337
if obj.role==controlTypes.Role.EDITABLETEXT and obj.UIAElement.cachedAutomationID.startswith('UIA_AutomationId_Word_Content'):

source/browseMode.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,20 @@ def _activatePosition(self, obj=None, info=None):
13361336
return
13371337
super(BrowseModeDocumentTreeInterceptor,self)._activatePosition(obj=obj)
13381338

1339+
def scrollToPosition(self, info: textInfos.TextInfo):
1340+
"""
1341+
Ensures the document is scrolled such that the given textInfo is visible on screen.
1342+
"""
1343+
obj=info.NVDAObjectAtStart
1344+
if not obj:
1345+
log.debugWarning("Invalid NVDAObjectAtStart")
1346+
return
1347+
if obj==self.rootNVDAObject:
1348+
return
1349+
obj.scrollIntoView()
1350+
if self.programmaticScrollMayFireEvent:
1351+
self._lastProgrammaticScrollTime = time.time()
1352+
13391353
def _set_selection(self, info, reason=OutputReason.CARET):
13401354
super(BrowseModeDocumentTreeInterceptor, self)._set_selection(info)
13411355
if isScriptWaiting() or not info.isCollapsed:
@@ -1355,15 +1369,7 @@ def _set_selection(self, info, reason=OutputReason.CARET):
13551369
else:
13561370
self._lastCaretMoveWasFocus = False
13571371
focusObj=info.focusableNVDAObjectAtStart
1358-
obj=info.NVDAObjectAtStart
1359-
if not obj:
1360-
log.debugWarning("Invalid NVDAObjectAtStart")
1361-
return
1362-
if obj==self.rootNVDAObject:
1363-
return
1364-
obj.scrollIntoView()
1365-
if self.programmaticScrollMayFireEvent:
1366-
self._lastProgrammaticScrollTime = time.time()
1372+
self.scrollToPosition(info)
13671373
if focusObj:
13681374
self.passThrough = self.shouldPassThrough(focusObj, reason=reason)
13691375
if (

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ If you need this functionality please assign a gesture to the appropriate script
4040
-
4141
- If a disabled addon is uninstalled and then re-installed it is re-enabled. (#12792)
4242
- Fixed bugs around updating and removing addons where the addon folder has been renamed or has files opened. (#12792, #12629)
43+
- Reading / navigating with browse mode in Microsoft Word via UI automation now ensures the document is always scrolled so that current browse mode position is visible, and that the caret position in focus mode correctly reflects the browse mode position. (#9611)
4344
-
4445

4546

0 commit comments

Comments
 (0)