Пример #1
0
	def handleSelectionChange(self):
		"""Pushes focus to the newly selected object."""
		if getattr(self,"_isHandlingSelectionChange",False):
			# #3394: A COM event can cause this function to run within itself.
			# This can cause double speaking, so stop here if we're already running.
			return
		self._isHandlingSelectionChange=True
		try:
			obj=self.selection
			if not obj:
				obj=IAccessible(windowHandle=self.windowHandle,IAccessibleObject=self.IAccessibleObject,IAccessibleChildID=self.IAccessibleChildID)
			if obj and obj!=eventHandler.lastQueuedFocusObject:
				eventHandler.queueEvent("gainFocus",obj)
		finally:
			self._isHandlingSelectionChange=False
Пример #2
0
	def _iterEmbeddedObjs(self, hypertext, startIndex, direction):
		"""Recursively iterate through all embedded objects in a given direction starting at a given hyperlink index.
		"""
		log.debug("Starting at hyperlink index %d" % startIndex)
		for index in xrange(startIndex, hypertext.nHyperlinks if direction == "next" else -1, 1 if direction == "next" else -1):
			hl = hypertext.hyperlink(index)
			obj = IAccessible(IAccessibleObject=hl.QueryInterface(IAccessibleHandler.IAccessible2), IAccessibleChildID=0)
			log.debug("Yielding object at index %d" % index)
			yield obj
			try:
				objHt = obj.iaHypertext
			except:
				# This is a graphic, etc. which doesn't support text.
				continue
			log.debug("Object has hypertext. Recursing")
			for subObj in self._iterEmbeddedObjs(objHt, 0 if direction == "next" else objHt.nHyperlinks - 1, direction):
				yield subObj
Пример #3
0
	def _getTableCellAt(self,tableID,startPos,destRow,destCol):
		""" Override of documentBase.DocumentWithTableNavigation._getTableCellAt."""
		# Locate the table in the object ancestry of the given document position. 
		obj=startPos.NVDAObjectAtStart
		while not obj.table and obj!=startPos.obj.rootNVDAObject:
			obj=obj.parent
		if not obj.table:
			# No table could be found
			raise LookupError
		table = obj.table
		try:
			cell = table.IAccessibleTable2Object.cellAt(destRow - 1, destCol - 1).QueryInterface(IAccessible2)
			cell = IAccessible(IAccessibleObject=cell, IAccessibleChildID=0)
			# If the cell we fetched is marked as hidden, raise LookupError which will instruct calling code to try an adjacent cell instead.
			if cell.IA2Attributes.get('hidden'):
				raise LookupError("Found hidden cell") 
			# Return the position of the found cell
			return self.makeTextInfo(cell)
		except (COMError, RuntimeError):
			# Any of the above calls could throw a COMError, and sometimes a RuntimeError.
			# Treet this as the cell not existing.
			raise LookupError