|
Module treeInterceptorHandler
|
|
1
2
3
4
5
6
7 from logHandler import log
8 import baseObject
9 import api
10 import config
11 import braille
12
13 runningTable=set()
14
19
21
22 if obj.appModule and obj.appModule.sleepMode:
23 return None
24
25 ti=obj.treeInterceptor
26 if not ti:
27 try:
28 newClass=obj.treeInterceptorClass
29 except NotImplementedError:
30 return None
31 ti=newClass(obj)
32 if not ti.isAlive:
33 return None
34 runningTable.add(ti)
35 log.debug("Adding new treeInterceptor to runningTable: %s"%ti)
36 if ti.shouldPrepare:
37 ti.prepare()
38 return ti
39
45
47 try:
48 runningTable.remove(treeInterceptorObject)
49 except KeyError:
50 return
51 treeInterceptorObject.terminate()
52 log.debug("Killed treeInterceptor: %s" % treeInterceptorObject)
53
58
60 """Intercepts events and scripts for a tree of NVDAObjects.
61 When an NVDAObject is encompassed by this interceptor (i.e. it is beneath the root object or it is the root object itself),
62 events will first be executed on this interceptor if implemented.
63 Similarly, scripts on this interceptor take precedence over those of encompassed objects.
64 """
65
67 super(TreeInterceptor, self).__init__()
68 self._passThrough = False
69
70
71 self.rootNVDAObject = rootNVDAObject
72
74 """Terminate this interceptor.
75 This is called to perform any clean up when this interceptor is being destroyed.
76 """
77
79 """Whether this interceptor is alive.
80 If it is not alive, it will be removed.
81 """
82 raise NotImplementedError
83
84
85
86 isReady = True
87
89 """Determine whether an object is encompassed by this interceptor.
90 @param obj: The object in question.
91 @type obj: L{NVDAObjects.NVDAObject}
92 @return: C{True} if the object is encompassed by this interceptor.
93 @rtype: bool
94 """
95 raise NotImplementedError
96
98 """Whether most scripts should temporarily pass through this interceptor without being intercepted.
99 """
100 return self._passThrough
101
117
118 _cache_shouldPrepare=True
119 shouldPrepare=False
120
122 """Prepares this treeInterceptor so that it becomes ready to accept event/script input."""
123 raise NotImplementedError
124