|
31 | 31 | import brailleInput |
32 | 32 | import locationHelper |
33 | 33 | import aria |
| 34 | +from typing import Optional |
| 35 | + |
34 | 36 |
|
35 | 37 | class NVDAObjectTextInfo(textInfos.offsets.OffsetsTextInfo): |
36 | 38 | """A default TextInfo which is used to enable text review of information about widgets that don't support text content. |
@@ -365,26 +367,31 @@ def _get_treeInterceptorClass(self): |
365 | 367 | #: @type: bool |
366 | 368 | shouldCreateTreeInterceptor = True |
367 | 369 |
|
368 | | - def _get_treeInterceptor(self): |
369 | | - """Retrieves the treeInterceptor associated with this object. |
370 | | - If a treeInterceptor has not been specifically set, the L{treeInterceptorHandler} is asked if it can find a treeInterceptor containing this object. |
371 | | - @return: the treeInterceptor |
372 | | - @rtype: L{treeInterceptorHandler.TreeInterceptor} |
| 370 | + def _get_runningTreeInterceptor(self) -> Optional[treeInterceptorHandler.TreeInterceptor]: |
| 371 | + """Retrieves a running treeInterceptor associated with this object. |
| 372 | + @return: the treeInterceptor or C{None} if a treeInterceptor has not been specifically set. |
373 | 373 | """ |
374 | | - if hasattr(self,'_treeInterceptor'): |
375 | | - ti=self._treeInterceptor |
376 | | - if isinstance(ti,weakref.ref): |
377 | | - ti=ti() |
| 374 | + if hasattr(self, '_treeInterceptor'): |
| 375 | + ti = self._treeInterceptor |
| 376 | + if isinstance(ti, weakref.ref): |
| 377 | + ti = ti() |
378 | 378 | if ti and ti in treeInterceptorHandler.runningTable: |
379 | 379 | return ti |
380 | 380 | else: |
381 | 381 | self._treeInterceptor=None |
382 | 382 | return None |
383 | | - else: |
384 | | - ti=treeInterceptorHandler.getTreeInterceptor(self) |
| 383 | + |
| 384 | + def _get_treeInterceptor(self) -> Optional[treeInterceptorHandler.TreeInterceptor]: |
| 385 | + """Retrieves the treeInterceptor associated with this object. |
| 386 | + If a treeInterceptor has not been specifically set, the L{treeInterceptorHandler} is asked if it can find a treeInterceptor containing this object. |
| 387 | + @return: the treeInterceptor |
| 388 | + """ |
| 389 | + ti = self.runningTreeInterceptor |
| 390 | + if not ti: |
| 391 | + ti = treeInterceptorHandler.getTreeInterceptor(self) |
385 | 392 | if ti: |
386 | | - self._treeInterceptor=weakref.ref(ti) |
387 | | - return ti |
| 393 | + self._treeInterceptor = weakref.ref(ti) |
| 394 | + return ti |
388 | 395 |
|
389 | 396 | def _set_treeInterceptor(self,obj): |
390 | 397 | """Specifically sets a treeInterceptor to be associated with this object. |
|
0 commit comments