Example #1
0
    def script_showSelectionOptions(self, gesture):
        fakeSel = self.selection
        if fakeSel.isCollapsed:
            # Double click to access the toolbar; e.g. for annotations.
            try:
                p = fakeSel.pointAtStart
            except NotImplementedError:
                log.debugWarning("Couldn't get point to click")
                return
            log.debug("Double clicking")
            winUser.setCursorPos(p.x, p.y)
            mouseHandler.doPrimaryClick()
            mouseHandler.doPrimaryClick()
            return

        # The user makes a selection using browse mode virtual selection.
        # Update the selection in Kindle.
        # This will cause the options to appear.
        fakeSel.innerTextInfo.updateSelection()
        # The selection might have been adjusted to meet word boundaries,
        # so retrieve and report the selection from Kindle.
        # we can't just use self.makeTextInfo, as that will use our fake selection.
        realSel = self.rootNVDAObject.makeTextInfo(
            textInfos.POSITION_SELECTION)
        speech.speakTextSelected(realSel.text)
        # Remove our virtual selection and move the caret to the active end.
        fakeSel.innerTextInfo = realSel
        fakeSel.collapse(end=not self._lastSelectionMovedStart)
        self.selection = fakeSel
Example #2
0
	def _setCaretOffset(self,offset):
		rects=self._storyFieldsAndRects[1]
		if offset>=len(rects):
			raise RuntimeError("offset %d out of range")
		rect = rects[offset]
		x = rect.left
		y= rect.center.y
		x,y=windowUtils.logicalToPhysicalPoint(self.obj.windowHandle,x,y)
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(x,y)
		mouseHandler.doPrimaryClick()
		winUser.setCursorPos(oldX,oldY)
Example #3
0
 def doAction(self, index=None):
     if not index:
         l = self.location
         if l:
             x = l[0]
             y = l[1]
             oldX, oldY = winUser.getCursorPos()
             winUser.setCursorPos(x, y)
             mouseHandler.doPrimaryClick(releaseDelay=0.2)
             winUser.setCursorPos(oldX, oldY)
             return
     raise NotImplementedError
Example #4
0
	def script_list(self, gesture):
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, className="SysListView32"
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			mouseHandler.doPrimaryClick()
Example #5
0
	def activate(self):
		"""Activate this position.
		For example, this might activate the object at this position or click the point at this position.
		@raise NotImplementedError: If not supported.
		"""
		if not self.obj.isInForeground:
			raise NotImplementedError
		import mouseHandler
		import winUser
		p=self.pointAtStart
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(p.x,p.y)
		mouseHandler.doPrimaryClick()
		winUser.setCursorPos(oldX,oldY)
Example #6
0
	def _activateNVDAObject(self, obj):
		try:
			obj.doAction()
			return
		except:
			pass

		log.debugWarning("could not programmatically activate field, trying mouse")
		l=obj.location
		if not l:
			log.debugWarning("no location for field")
			return
		oldX,oldY=winUser.getCursorPos()
		winUser.setCursorPos(*l.center)
		mouseHandler.doPrimaryClick()
		winUser.setCursorPos(oldX,oldY)
Example #7
0
	def script_searchList(self, gesture):
		where = self.getWhere()
		if not hasattr(where, "IAccessibleChildID") or where.IAccessibleChildID != 6:
			return
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, controlID=2833
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			mouseHandler.doPrimaryClick()
Example #8
0
	def script_readOnlyEdit(self, gesture):
		where = self.getWhere()
		if hasattr(where, "IAccessibleChildID") and where.IAccessibleChildID == 9:
			cID = -1
		else:
			cID = None
		try:
			obj = NVDAObjects.IAccessible.getNVDAObjectFromEvent(
				windowUtils.findDescendantWindow(
					api.getForegroundObject().windowHandle, visible=True, className="RichEdit20W", controlID=cID
				), winUser.OBJID_CLIENT, 0
			)
		except LookupError:
			return
		if obj != api.getFocusObject():
			api.moveMouseToNVDAObject(obj)
			api.setMouseObject(obj)
			mouseHandler.doPrimaryClick()
Example #9
0
 def _activateNVDAObject(self, obj):
     while obj and obj != self.rootNVDAObject:
         try:
             obj.doAction()
             break
         except:
             log.debugWarning("doAction failed")
         if obj.hasIrrelevantLocation:
             # This check covers invisible, off screen and a None location
             log.debugWarning("No relevant location for object")
             obj = obj.parent
             continue
         location = obj.location
         if not location.width or not location.height:
             obj = obj.parent
             continue
         log.debugWarning("Clicking with mouse")
         oldX, oldY = winUser.getCursorPos()
         winUser.setCursorPos(*location.center)
         mouseHandler.doPrimaryClick()
         winUser.setCursorPos(oldX, oldY)
         break
Example #10
0
 def script_enter(self, gesture):
     api.moveMouseToNVDAObject(self)
     api.setMouseObject(self)
     mouseHandler.doPrimaryClick()
     mouseHandler.doPrimaryClick()