Skip to content

Commit 3fbcb02

Browse files
Merge 9b121c8 into 8dcddfd
2 parents 8dcddfd + 9b121c8 commit 3fbcb02

7 files changed

Lines changed: 38 additions & 7 deletions

File tree

source/NVDAObjects/IAccessible/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ class IA2TextTextInfo(textInfos.offsets.OffsetsTextInfo):
122122

123123
detectFormattingAfterCursorMaybeSlow=False
124124

125+
def scrollIntoView(self):
126+
self.obj.IAccessibleTextObject.scrollSubstringTo(
127+
self._startOffset, self._endOffset,
128+
IA2.IA2_SCROLL_TYPE_TOP_LEFT
129+
)
130+
125131
def _get_encoding(self):
126132
return super().encoding
127133

source/NVDAObjects/UIA/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545

4646
class UIATextInfo(textInfos.TextInfo):
4747

48+
def scrollIntoView(self):
49+
self._rangeObj.scrollIntoView(True)
50+
4851
_cache_controlFieldNVDAObjectClass=True
4952
def _get_controlFieldNVDAObjectClass(self):
5053
"""

source/NVDAObjects/window/winword.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,12 @@ def _normalizeFormatField(self,field,extraDetail=False):
888888
field['line-prefix']=mapPUAToUnicode.get(bullet,bullet)
889889
return field
890890

891+
def scrollIntoView(self):
892+
try:
893+
self.obj.WinwordWindowObject.ScrollIntoView(self._rangeObj, True)
894+
except COMError:
895+
log.debugWarning("Can't scroll", exc_info=True)
896+
891897
def expand(self,unit):
892898
if unit==textInfos.UNIT_LINE:
893899
try:

source/browseMode.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,7 @@ def _get_focusableNVDAObjectAtStart(self):
12371237
return self.obj.rootNVDAObject
12381238
return item.obj
12391239

1240+
12401241
class BrowseModeDocumentTreeInterceptor(documentBase.DocumentWithTableNavigation,cursorManager.CursorManager,BrowseModeTreeInterceptor,treeInterceptorHandler.DocumentTreeInterceptor):
12411242

12421243
programmaticScrollMayFireEvent = False
@@ -1354,13 +1355,7 @@ def _set_selection(self, info, reason=OutputReason.CARET):
13541355
else:
13551356
self._lastCaretMoveWasFocus = False
13561357
focusObj=info.focusableNVDAObjectAtStart
1357-
obj=info.NVDAObjectAtStart
1358-
if not obj:
1359-
log.debugWarning("Invalid NVDAObjectAtStart")
1360-
return
1361-
if obj==self.rootNVDAObject:
1362-
return
1363-
obj.scrollIntoView()
1358+
info.scrollIntoView()
13641359
if self.programmaticScrollMayFireEvent:
13651360
self._lastProgrammaticScrollTime = time.time()
13661361
if focusObj:

source/textInfos/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,13 @@ def getMathMl(self, field):
640640
"""
641641
raise NotImplementedError
642642

643+
def scrollIntoView(self):
644+
"""
645+
Scrolls the window to ensure that this text range is visible.
646+
"""
647+
raise NotImplementedError
648+
649+
643650
RE_EOL = re.compile("\r\n|[\n\r]")
644651
def convertToCrlf(text):
645652
"""Convert a string so that it contains only CRLF line endings.

source/treeInterceptorHandler.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ def _get__rangeObj(self):
186186
def _set__rangeObj(self,r):
187187
self.innerTextInfo._rangeObj=r
188188

189+
def scrollIntoView(self):
190+
self.innerTextInfo.scrollIntoView()
191+
189192
def _get_locationText(self):
190193
return self.innerTextInfo.locationText
191194

source/virtualBuffers/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,17 @@ def getMathMl(self, field):
394394
obj = self.obj.getNVDAObjectFromIdentifier(docHandle, nodeId)
395395
return obj.mathMl
396396

397+
def scrollIntoView(self):
398+
# Scroll the deepest object at this point into view.
399+
obj = self.NVDAObjectAtStart
400+
if not obj:
401+
return
402+
if obj == self.obj.rootNVDAObject:
403+
# However never scroll to the document itself
404+
return
405+
obj.scrollIntoView()
406+
407+
397408
class VirtualBuffer(browseMode.BrowseModeDocumentTreeInterceptor):
398409

399410
TextInfo=VirtualBufferTextInfo

0 commit comments

Comments
 (0)