Beispiel #1
0
def getCaretRect(obj: Optional[TextContainerObject] = None) -> locationHelper.RectLTRB:
	if obj is None:
		obj = api.getCaretObject()
	if api.isObjectInActiveTreeInterceptor(obj):
		obj = obj.treeInterceptor
	if api.isNVDAObject(obj):
		# Import late to avoid circular import
		from displayModel import getCaretRect
		# Check whether there is a caret in the window.
		# Note that, even windows that don't have navigable text could have a caret, such as in Excel.
		try:
			return locationHelper.RectLTRB.fromCompatibleType(getCaretRect(obj))
		except RuntimeError:
			if not obj._hasNavigableText:
				raise LookupError
	try:
		caretInfo = obj.makeTextInfo(textInfos.POSITION_CARET)
	except (NotImplementedError, RuntimeError):
		# Try a selection
		try:
			caretInfo = obj.makeTextInfo(textInfos.POSITION_SELECTION)
		except (NotImplementedError, RuntimeError):
			# There is nothing to do here
			raise LookupError
	return getRectFromTextInfo(caretInfo)
 def handleFocusChange(self, obj):
     self.updateContextRect(context=Context.FOCUS, obj=obj)
     if not api.isObjectInActiveTreeInterceptor(obj):
         self.contextToRectMap.pop(Context.BROWSEMODE, None)
     else:
         self.handleBrowseModeMove()