forked from nvaccess/nvda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreenExplorer.py
61 lines (57 loc) · 1.67 KB
/
screenExplorer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import api
import tones
import controlTypes
import textInfos
import locationHelper
import speech
class ScreenExplorer(object):
updateReview=False
def __init__(self):
self._obj=None
self._pos=None
def moveTo(self,x,y,new=False,unit=textInfos.UNIT_LINE):
obj=api.getDesktopObject().objectFromPoint(x,y)
prevObj=None
while obj and obj.beTransparentToMouse:
prevObj=obj
obj=obj.parent
if not obj or (obj.presentationType!=obj.presType_content and obj.role!=controlTypes.Role.PARAGRAPH):
obj=prevObj
if not obj:
return
hasNewObj=False
if obj!=self._obj:
self._obj=obj
hasNewObj=True
if self.updateReview:
api.setNavigatorObject(obj)
else:
obj=self._obj
pos=None
if obj.treeInterceptor:
try:
pos=obj.treeInterceptor.makeTextInfo(obj)
except LookupError:
pos=None
if pos:
obj=obj.treeInterceptor.rootNVDAObject
if hasNewObj and self._obj and obj.treeInterceptor is self._obj.treeInterceptor:
hasNewObj=False
if not pos:
try:
pos=obj.makeTextInfo(locationHelper.Point(x,y))
except (NotImplementedError,LookupError):
pass
if pos: pos.expand(unit)
if pos and self.updateReview:
api.setReviewPosition(pos)
speechCanceled=False
if hasNewObj:
speech.cancelSpeech()
speechCanceled=True
speech.speakObject(obj)
if pos and (new or not self._pos or pos.__class__!=self._pos.__class__ or pos.compareEndPoints(self._pos,"startToStart")!=0 or pos.compareEndPoints(self._pos,"endToEnd")!=0):
self._pos=pos
if not speechCanceled:
speech.cancelSpeech()
speech.speakTextInfo(pos, reason=controlTypes.OutputReason.CARET)