def script_startExploration(self, gesture): self.configVars() with measureTime("Toolbars found in"): self.findToolbars() self.initialFilterBars() if self.bars: self.populateBar(self.bars[self.barIndex]) if not self.bars: # Translators: message in applications without toolbars ui.message(_("No toolbar found")) return # a backup of various info, useful later self.startSnap["focus"] = api.getFocusObject() self.startSnap["nav"] = api.getNavigatorObject() self.startSnap["foreground"] = api.getForegroundObject() self.startSnap["pid"] = api.getFocusObject().processID self.startSnap["reviewMode"] = review.getCurrentMode() # declare exploration started self.exploring = True # set object navigation active review.setCurrentMode("object", updateReviewPosition=False) # see script_explore for gesture explanation for direction in ("up", "right", "down", "left"): self.bindGesture("kb:%sArrow" % direction, "explore") self.bindGesture("kb:escape", "finish") self.bindGesture("kb:enter", "objActivate") self.bindGesture("kb:space", "objLeftClick") self.bindGesture("kb:applications", "objRightClick") self.bindGesture("kb:shift+f10", "objRightClick") bar = self.bars[self.barIndex] api.setNavigatorObject(bar) speech.speakObject(bar, reason=REASON_FOCUS)
def moveInTree(self, increment, errorMessage, unbounded=False, op=operator.eq, speakOnly=False, moveCount=1): obj = api.getFocusObject() level = self.getLevel(obj) found = False levels = [] while True: if increment > 0: obj = obj.next else: obj = obj.previous newLevel = self.getLevel(obj) if newLevel is None: break if op(newLevel, level): found = True level = newLevel result = obj moveCount -= 1 if moveCount == 0: break elif newLevel < level: # Not found in this subtree if not unbounded: break levels.append(newLevel ) if found: self.beeper.fancyCrackle(levels, volume=getConfig("crackleVolume")) if not speakOnly: result.setFocus() else: speech.speakObject(result) else: self.endOfDocument(errorMessage)
def approbes(self, listEvent, logger): try: eventsNavList = [] for event in reversed(listEvent): if isinstance(event, NavigationByKeyL): ui.message("Cantidad de Hijos") speech.speakObject(event.navegado) ui.message(str(len(event.navegado.children))) eventsNavList.append(event) ui.message("Objeto Foco") (leftf, topf, widthf, heightf) = event.foco.location ui.message("Objeto navegado") (left, top, width, height) = event.navegado.location ui.message("Absolutas") params = urllib.urlencode({ "threat": "NavigationListMenu", "finalTop": "finaltopp", "locationNavegador": (left, top, width, height), "timeStamp": event.timeStamp, "navegado": event.navegado, "url": event.url }) logger.logEven('NavigationByKeyH', params, False) ui.message( "Cantidad de Navegacion de listas NavigationBetweenList") ui.message(str(len(eventsNavList))) except: ui.message("Error al Procesar finder de list")
def setTemporaryAudioOutputDevice(outputDevice): global _temporaryOutputDevice curSynth = getSynth() prevOutputDevice = config.conf["speech"]["outputDevice"] ret = setOutputDevice(curSynth, outputDevice) if not ret: return def confirm(synth, prevOutputDevice): global _temporaryOutputDevice from ..settings import _addonConfigManager timeToLive = _addonConfigManager.getConfirmAudioDeviceChangeTimeOut() from ..utils import PutWindowOnForeground dialog = ConfirmOutputDevice(None, timeToLive) with dialog as d: PutWindowOnForeground(d.GetHandle(), 10, 0.5) res = d.ShowModal() d.Destroy() if res == wx.ID_OK: _temporaryOutputDevice = outputDevice else: # return to previous output device setOutputDevice(synth, prevOutputDevice) from ..settings import toggleConfirmAudioDeviceChangeAdvancedOption if toggleConfirmAudioDeviceChangeAdvancedOption(False): wx.CallLater(50, confirm, curSynth, prevOutputDevice) else: _temporaryOutputDevice = outputDevice obj = api.getFocusObject() speech.speakObject(obj)
def script_notifications(self, gesture): obj = self.getPropertyPage().simpleLastChild.simplePrevious if obj.role == controlTypes.ROLE_ALERT: if api.getFocusObject().parent == obj: # Already focused ui.message(shared.getAlertText(obj)) speech.speakObject(api.getFocusObject()) return if shared.focusAlertPopup(obj): return if self.notificationHistory: if scriptHandler.getLastScriptRepeatCount() == 1: ui.browseableMessage( "\n".join([ "%s: %s" % (shared.elapsedFromTimestamp( notification[0]), notification[1]) for notification in self.notificationHistory ]), "%s - Thunderbird" % _("Notification History")) else: #TRANSLATORS: read the last notification ui.message( _("Last alert, %s: %s") % (shared.elapsedFromTimestamp( self.notificationHistory[-1][0]), self.notificationHistory[-1][1])) else: #TRANSLATORS: there is no recent notification in Thunderbird ui.message(_("There is no notification"))
def dragAndDrop(self, drop_x, drop_y): self.kbFinish() x, y = self.dragFromPosition if api.getDesktopObject().objectFromPoint(x, y) != self.objectToDrag: self.error(_("Cannot find the object marked.")) return win32api.SetCursorPos((x, y)) if winUser.getKeyState(winUser.VK_LBUTTON) & 32768: winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTDOWN, 0, 1, None, None) ui.message(_("click in %d, %d") % win32api.GetCursorPos()) sleep(1.0) ui.message(_("dragging")) sleep(0.5) win32api.SetCursorPos((drop_x, drop_y)) obj = api.getDesktopObject().objectFromPoint(drop_x, drop_y) ui.message(_("moved to %d, %d") % win32api.GetCursorPos()) sleep(0.5) winUser.mouse_event(winUser.MOUSEEVENTF_LEFTUP, 0, 0, None, None) sleep(1.0) x, y = self.dragFromPosition if api.getDesktopObject().objectFromPoint(x, y) != self.objectToDrag: ui.message(_("dropped on ")) speech.speakObject(obj, reason=controlTypes.REASON_MOUSE) else: tones.beep(500, 100) self.objectToDrag = None
def script_mouseCursorInfo(self, gesture): if scriptHandler.getLastScriptRepeatCount() == 2: ui.message( _("Window in %d, %d. Width %d, height %d") % api.getForegroundObject().location) return if scriptHandler.getLastScriptRepeatCount() == 1: if not self.objectToDrag: ui.message(_("without selection for drag and drop")) return speech.speakObject(self.objectToDrag, reason=controlTypes.REASON_MOUSE) ui.message(_(" marked for drag and drop")) x, y = self.dragFromPosition if api.getDesktopObject().objectFromPoint(x, y) != self.objectToDrag: ui.message(_("(inaccessible from here)")) return fg = api.getForegroundObject() x, y = win32api.GetCursorPos() ui.message(_("Mouse cursor is on %d, %d above ") % (x, y)) mouse = api.getDesktopObject().objectFromPoint(x, y) speech.speakObject(mouse, reason=controlTypes.REASON_MOUSE) if fg.appModule.appModuleName != mouse.appModule.appModuleName: ui.message(_("(outside of the active window)")) if winUser.getKeyState(winUser.VK_LBUTTON) & 32768: ui.message(_("Left button locked")) if winUser.getKeyState(winUser.VK_RBUTTON) & 32768: ui.message(_("Right button locked")) ui.message(_("%s cursor") % mouseHandler.curMouseShape)
def callback(obj, oldspeechMode): api.processPendingEvents() speech.cancelSpeech() speech.speechMode = oldSpeechMode api.setNavigatorObject(obj) api.moveMouseToNVDAObject(obj) speech.speakObject(obj)
def event_gainFocus(self): if winUser.getKeyState( KeyboardInputGesture.fromName("Control").vkCode) in (0, 1): try: self.states.remove(controlTypes.STATE_SELECTED) except KeyError: pass if not self.name: self.name = " " self.reportHeaders = config.conf['documentFormatting'][ 'reportTableHeaders'] if versionInfo.version_year * 100 + versionInfo.version_major >= 201802: config.conf['documentFormatting'][ 'reportTableHeaders'] = True if config.conf['calibre'][ 'reportTableHeaders'] == "st" else False if self.columnHeaderText and ( (versionInfo.version_year * 100 + versionInfo.version_major < 201802 and config.conf['documentFormatting']['reportTableHeaders']) or (versionInfo.version_year * 100 + versionInfo.version_major >= 201802 and config.conf['calibre']['reportTableHeaders'] == "cl")): # Reporting table headers at classic style (used in previous versions of NVDA or in new versions if read only column headers is selected in preferences) if not self.inTitleColumn and not self.inAuthorColumn: self.description = self.columnHeaderText speakObject(self, controlTypes.REASON_CARET) braille.handler.handleGainFocus(self)
def event_gainFocus(self): isMultitab = False ch = self.simpleFirstChild while ch: if ch.IAccessibleRole == controlTypes.ROLE_TAB: isMultitab = True break ch = ch.next try: if isMultitab: self.tabItems = filter( lambda i: i.IAccessibleRole == controlTypes.ROLE_HEADING1 and i.next.IAccessibleRole == controlTypes.ROLE_TAB, self.recursiveDescendants) except AttributeError: self.tabItems = [] if self.tabItems: self.role = controlTypes.ROLE_TAB fg = api.getForegroundObject() if not hasattr(fg, "tabIndex"): setattr(fg, "tabIndex", 0) self.__updateTab(fg.tabIndex) else: try: if self.simpleFirstChild.IAccessibleRole == controlTypes.ROLE_HEADING1: self.name = self.simpleFirstChild.name except AttributeError: pass self.name = self.simpleParent.name if not self.name and self.simpleParent.role == 4 else self.name speakObject(self)
def event_alert(self): if not config.conf["presentation"]["reportHelpBalloons"]: return speech.speakObject(self, reason=controlTypes.REASON_FOCUS) # Ideally, we wouldn't use getPropertiesBraille directly. braille.handler.message( braille.getPropertiesBraille(name=self.name, role=self.role))
def script_navigatorObject_current(self,gesture): curObject=api.getNavigatorObject() if not isinstance(curObject,NVDAObject): speech.speakMessage(_("no navigator object")) return if scriptHandler.getLastScriptRepeatCount()>=1: if curObject.TextInfo!=NVDAObjectTextInfo: textList=[] if curObject.name and isinstance(curObject.name, basestring) and not curObject.name.isspace(): textList.append(curObject.name) try: info=curObject.makeTextInfo(textInfos.POSITION_SELECTION) if not info.isCollapsed: textList.append(info.text) else: info.expand(textInfos.UNIT_LINE) if not info.isCollapsed: textList.append(info.text) except (RuntimeError, NotImplementedError): # No caret or selection on this object. pass else: textList=[prop for prop in (curObject.name, curObject.value) if prop and isinstance(prop, basestring) and not prop.isspace()] text=" ".join(textList) if len(text)>0 and not text.isspace(): if scriptHandler.getLastScriptRepeatCount()==1: speech.speakSpelling(text) else: if api.copyToClip(text): speech.speakMessage(_("%s copied to clipboard")%text) else: speech.speakObject(curObject,reason=speech.REASON_QUERY)
def event_show(self): if not config.conf["presentation"]["reportTooltips"]: return speech.speakObject(self, reason=controlTypes.OutputReason.FOCUS) # Ideally, we wouldn't use getPropertiesBraille directly. braille.handler.message( braille.getPropertiesBraille(name=self.name, role=self.role))
def approbes(self, listEvent, logger): try: for event in reversed(listEvent): if isinstance(event, NavigationByKeyH): ui.message("Objeto Foco") (leftf, topf, widthf, heightf) = event.foco.location speech.speakObject(event.foco) ui.message("Objeto navegado") (left, top, width, height) = event.navegado.location ui.message("Absolutas") (deskLeft, deskTop, deskWidth, deskHeight) = api.getDesktopObject().location speech.speakObject(event.navegado) #finaltop=float(top-deskTop) params = urllib.urlencode({ "threat": "FlashScrolingKeyH", "desktop": (deskLeft, deskTop, deskWidth, deskHeight), "foco Location": (leftf, topf, widthf, heightf), "finalTop": "finaltop", "locationNavegador": (left, top, width, height), "timeStamp": event.timeStamp, "navegado": event.navegado, "url": event.url }) logger.logEven('NavigationByKeyH', params, False) ui.message("enviando") except: ui.message("Error al Procesar finder NavigationByKeyH")
def script_header(self, gesture): obj = self.getHeader() if obj is None: return api.setNavigatorObject(obj) api.moveMouseToNVDAObject(obj) api.setMouseObject(obj) speech.speakObject(obj)
def event_focusEntered(self): if self.role in (controlTypes.ROLE_MENUBAR, controlTypes.ROLE_POPUPMENU, controlTypes.ROLE_MENUITEM): speech.cancelSpeech() return if self.isPresentableFocusAncestor: speech.speakObject(self, reason=controlTypes.REASON_FOCUSENTERED)
def script_skip(self, gesture): gesture.send() focusObject = api.getFocusObject() if isinstance(focusObject, NVDAObject): speakObject(focusObject, reason=controlTypes.REASON_CHANGE if hasattr( controlTypes, "REASON_CHANGE") else controlTypes.OutputReason.CHANGE)
def script_navigatorObject_toFocus(self,gesture): obj=api.getFocusObject() try: pos=obj.makeTextInfo(textInfos.POSITION_CARET) except (NotImplementedError,RuntimeError): pos=obj.makeTextInfo(textInfos.POSITION_FIRST) api.setReviewPosition(pos) speech.speakMessage(_("move to focus")) speech.speakObject(obj,reason=speech.REASON_QUERY)
def __updateTab(self, index): if self.focusedWidget: return fg = api.getForegroundObject() max = len(self.tabItems) - 1 index = 0 if index > max else max if index < 0 else index setattr(fg, "tabIndex", index) self.name = self.tabItems[fg.tabIndex].name speakObject(self)
def _moveToColumn(self, obj): if not obj: ui.message(_("edge of table")) return if obj is not self: # Use the focused copy of the row as the parent for all cells to make comparison faster. obj.parent = self api.setNavigatorObject(obj) speech.speakObject(obj, reason=controlTypes.REASON_FOCUS)
def script_reportCurrentFocus(self,gesture): focusObject=api.getFocusObject() if isinstance(focusObject,NVDAObject): if scriptHandler.getLastScriptRepeatCount()==0: speech.speakObject(focusObject, reason=speech.REASON_QUERY) else: speech.speakSpelling(focusObject.name) else: speech.speakMessage(_("no focus"))
def _moveToColumn(self, obj): if not obj: ui.message(_("Edge of table")) return if obj is not self: # Use the focused copy of the row as the parent for all cells to make comparison faster. obj.parent = self api.setNavigatorObject(obj) speech.speakObject(obj, reason=controlTypes.REASON_FOCUS)
def script_headerOptions(self, gesture): if self.parent.simpleParent.role == controlTypes.ROLE_DIALOG: return obj = self.parent.getChild(1) while obj.name != self.columnHeaderText and obj.role == controlTypes.ROLE_TABLECOLUMNHEADER: obj = obj.next api.setNavigatorObject(obj) speakObject(obj) winUser.setCursorPos(self.location[0] + 2, obj.location[1] + 2) winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTDOWN, 0, 0, None, None) winUser.mouse_event(winUser.MOUSEEVENTF_RIGHTUP, 0, 0, None, None)
def generateObjectSubtreeSpeech(obj,indexGen): index=indexGen.next() speech.speakObject(obj,reason=controlTypes.REASON_SAYALL,index=index) yield obj,index child=obj.simpleFirstChild while child: childSpeech=generateObjectSubtreeSpeech(child,indexGen) for r in childSpeech: yield r child=child.simpleNext
def script_navigatorObject_moveToObjectAtFlatReviewPosition(self,gesture): pos=api.getReviewPosition() try: obj=pos.NVDAObjectAtStart except NotImplementedError: obj=None if obj and obj!=pos.obj: api.setNavigatorObject(obj) speech.speakObject(obj) else: speech.speakMessage(_("No object at flat review position"))
def speakDescendantObjects(self,hashList=None): """Speaks all the descendants of this object. """ if hashList is None: hashList=[] for child in self.children: h=hash(child) if h not in hashList: hashList.append(h) speech.speakObject(child) child.speakDescendantObjects(hashList=hashList)
def script_previousWidget(self, gesture): if not self.focusedWidget: KeyboardInputGesture.fromName("shift+tab").send() return self.focusedWidget = self.focusedWidget.simplePrevious if self.focusedWidget: api.setNavigatorObject(self.focusedWidget) speakObject(self.focusedWidget) else: api.setNavigatorObject(self) speakObject(self)
def cancelTemporaryAudioOutputDevice(): global _temporaryOutputDevice if not _temporaryOutputDevice: return # back to speech configuration output device outputDevice = config.conf["speech"]["outputDevice"] synth = getSynth() setOutputDevice(synth, outputDevice) _temporaryOutputDevice = None obj = api.getFocusObject() speech.speakObject(obj)
def script_navigatorObject_firstChild(self,gesture): curObject=api.getNavigatorObject() if not isinstance(curObject,NVDAObject): speech.speakMessage(_("no navigator object")) return simpleReviewMode=config.conf["reviewCursor"]["simpleReviewMode"] curObject=curObject.simpleFirstChild if simpleReviewMode else curObject.firstChild if curObject is not None: api.setNavigatorObject(curObject) speech.speakObject(curObject,reason=speech.REASON_QUERY) else: speech.speakMessage(_("No children"))
def finish(self, restoreMode=False, restoreObjects=False): self.exploring = False self.clearGestureBindings() self.bindGestures(self.__gestures) # restore initial objects and review mode if restoreMode: review.setCurrentMode(self.startSnap["reviewMode"], updateReviewPosition=False) if restoreObjects: api.setFocusObject(self.startSnap["focus"]) api.setNavigatorObject(self.startSnap["nav"]) speech.speakObject(self.startSnap["focus"], reason=REASON_FOCUS)
def next(self): if not self.walker: # We were stopped. return if self.prevObj: # We just started speaking this object, so move the navigator to it. api.setNavigatorObject(self.prevObj, isFocus=lastSayAllMode==CURSOR_CARET) # Move onto the next object. self.prevObj = obj = next(self.walker, None) if not obj: return # Call this method again when we start speaking this object. callbackCommand = speech.CallbackCommand(self.next, name="say-all:next") speech.speakObject(obj, reason=controlTypes.REASON_SAYALL, _prefixSpeechCommand=callbackCommand)
def event_treeInterceptor_gainFocus(self): speech.speakObject(self.rootNVDAObject, reason=controlTypes.REASON_FOCUS) try: info = self.makeTextInfo(textInfos.POSITION_SELECTION) except RuntimeError: pass else: if info.isCollapsed: info.expand(textInfos.UNIT_LINE) speech.speakTextInfo(info, unit=textInfos.UNIT_LINE, reason=controlTypes.REASON_CARET) else: speech.speakSelectionMessage(_("selected %s"), info.text) braille.handler.handleGainFocus(self) self.initAutoSelectDetection()
def moveTo(self, x, y, new=False, unit=textInfos.UNIT_LINE): obj = api.getDesktopObject().objectFromPoint(x, y) prevObj = None while obj and obj.beTransparentToMouse: prevObj = obj obj = obj.parent if not obj or (obj.presentationType != obj.presType_content and obj.role != controlTypes.ROLE_PARAGRAPH): obj = prevObj if not obj: return hasNewObj = False if obj != self._obj: self._obj = obj hasNewObj = True if self.updateReview: api.setNavigatorObject(obj) else: obj = self._obj pos = None if obj.treeInterceptor: try: pos = obj.treeInterceptor.makeTextInfo(obj) except LookupError: pos = None if pos: obj = obj.treeInterceptor.rootNVDAObject if hasNewObj and self._obj and obj.treeInterceptor is self._obj.treeInterceptor: hasNewObj = False if not pos: try: pos = obj.makeTextInfo(locationHelper.Point(x, y)) except (NotImplementedError, LookupError): pass if pos: pos.expand(unit) if pos and self.updateReview: api.setReviewPosition(pos) speechCanceled = False if hasNewObj: speech.cancelSpeech() speechCanceled = True speech.speakObject(obj) if pos and (new or not self._pos or pos.__class__ != self._pos.__class__ or pos.compareEndPoints(self._pos, "startToStart") != 0 or pos.compareEndPoints(self._pos, "endToEnd") != 0): self._pos = pos if not speechCanceled: speech.cancelSpeech() speech.speakTextInfo(pos, reason=controlTypes.OutputReason.CARET)
def script_nextWidget(self, gesture): if not self.tabItems: KeyboardInputGesture.fromName("tab").send() return fg = api.getForegroundObject() if not self.focusedWidget: self.focusedWidget = self.tabItems[ fg.tabIndex].next.simpleFirstChild else: self.focusedWidget = self.focusedWidget.simpleNext if self.focusedWidget: api.setNavigatorObject(self.focusedWidget) speakObject(self.focusedWidget) else: KeyboardInputGesture.fromName("tab").send()
def script_moveToColumn(self, gesture): try: index = int(gesture.keyName[-1]) - 1 except AttributeError: index = int(gesture.mainKeyName[-1]) - 1 if index >= self.childCount: #TRANSLATORS: message spoken when there aren't more columns in the tree ui.message(_("There are not more columns")) return obj = self.getChild(index) if not obj.name: #TRANSLATORS: empty object name obj.name = _("empty") obj.states = None api.setNavigatorObject(obj) speech.speakObject(obj, reason=controlTypes.REASON_FOCUS)
def script_f7KeyStroke(self, gesture): def verify(oldSpeechMode): api.processPendingEvents() speech.cancelSpeech() speech.speechMode = oldSpeechMode focus = api.getFocusObject() from .ww_spellingChecker import SpellingChecker sc = SpellingChecker(focus, self.WinwordVersion) if not sc.isInSpellingChecker(): return if focus.role == controlTypes.ROLE_PANE: # focus on the pane not not on an object of the pane queueHandler.queueFunction( queueHandler.eventQueue, speech.speakMessage, # Translators: message to ask user to hit tab key. _("Hit tab to move focus in the spelling checker pane")) else: sc.sayErrorAndSuggestion(title=True, spell=False, focusOnSuggestion=True) queueHandler.queueFunction(queueHandler.eventQueue, speech.speakObject, focus, controlTypes.REASON_FOCUS) stopScriptTimer() if not self.isSupportedVersion(): gesture.send() return focus = api.getFocusObject() from .ww_spellingChecker import SpellingChecker sc = SpellingChecker(focus, self.WinwordVersion) if not sc.isInSpellingChecker(): # moving to spelling checker oldSpeechMode = speech.speechMode speech.speechMode = speech.speechMode_off gesture.send() core.callLater(500, verify, oldSpeechMode) return # moving to document selection winwordWindowObject = self.WinwordWindowObject selection = winwordWindowObject.Selection selection.Characters(1).GoTo() time.sleep(0.1) api.processPendingEvents() speech.cancelSpeech() speech.speakObject(api.getFocusObject(), controlTypes.REASON_FOCUS)
def moveToItem(self, index): toolPaneItems = filter( lambda item: controlTypes.State.INVISIBLE not in item.states and controlTypes.State.UNAVAILABLE not in item.states, self.playbackControls) if len(toolPaneItems) == 0: #TRANSLATORS: Message when there are no playback controls visible on screen, or the addon can't find them. ui.message(_("There are no controls available")) return () if index >= len(toolPaneItems): index = 0 if index < 0: index = len(toolPaneItems) - 1 speakObject(toolPaneItems[index]) api.setNavigatorObject(toolPaneItems[index]) api.setMouseObject(toolPaneItems[index]) self.appModule.tpItemIndex = index
def moveTo(self,x,y,new=False,unit=textInfos.UNIT_LINE): obj=api.getDesktopObject().objectFromPoint(x,y) prevObj=None while obj and obj.beTransparentToMouse: prevObj=obj obj=obj.parent if not obj or (obj.presentationType!=obj.presType_content and obj.role!=controlTypes.ROLE_PARAGRAPH): obj=prevObj if not obj: return hasNewObj=False if obj!=self._obj: self._obj=obj hasNewObj=True if self.updateReview: api.setNavigatorObject(obj) else: obj=self._obj pos=None if obj.treeInterceptor: try: pos=obj.treeInterceptor.makeTextInfo(obj) except LookupError: pos=None if pos: obj=obj.treeInterceptor.rootNVDAObject if hasNewObj and self._obj and obj.treeInterceptor is self._obj.treeInterceptor: hasNewObj=False if not pos: try: pos=obj.makeTextInfo(textInfos.Point(x,y)) except (NotImplementedError,LookupError): pass if pos: pos.expand(unit) if pos and self.updateReview: api.setReviewPosition(pos) speechCanceled=False if hasNewObj: speech.cancelSpeech() speechCanceled=True speech.speakObject(obj) if pos and (new or not self._pos or pos.__class__!=self._pos.__class__ or pos.compareEndPoints(self._pos,"startToStart")!=0 or pos.compareEndPoints(self._pos,"endToEnd")!=0): self._pos=pos if not speechCanceled: speech.cancelSpeech() speech.speakTextInfo(pos,reason=controlTypes.REASON_CARET)
def readObjectsHelper_generator(obj): levelsIndexMap={} updateObj=obj keepReading=True keepUpdating=True indexCount=0 lastSpokenIndex=0 endIndex=0 while keepUpdating: while speech.isPaused: yield continue if keepReading: speech.speakObject(obj,index=indexCount,reason=speech.REASON_SAYALL) up=[] down=[] obj=obj.getNextInFlow(up=up,down=down) if not obj: endIndex=indexCount keepReading=False indexCount+=1 levelsIndexMap[indexCount]=(len(up),len(down)) spokenIndex=speech.getLastSpeechIndex() if spokenIndex is None: spokenIndex=0 for count in range(spokenIndex-lastSpokenIndex): upLen,downLen=levelsIndexMap.get(lastSpokenIndex+count+1,(0,0)) if upLen==0 and downLen==0: tones.beep(880,50) if upLen>0: for count in range(upLen+1): tones.beep(880*(1.25**count),50) time.sleep(0.025) if downLen>0: for count in range(downLen+1): tones.beep(880/(1.25**count),50) time.sleep(0.025) updateObj=updateObj.nextInFlow api.setNavigatorObject(updateObj) if not keepReading and spokenIndex>=endIndex: keepUpdating=False lastSpokenIndex=spokenIndex yield
def event_focusEntered(self): if self.role in (controlTypes.ROLE_MENUBAR,controlTypes.ROLE_POPUPMENU,controlTypes.ROLE_MENUITEM): speech.cancelSpeech() return if self.isPresentableFocusAncestor: speech.speakObject(self,reason=speech.REASON_FOCUSENTERED)
def reportFocus(self): """Announces this object in a way suitable such that it gained focus. """ speech.speakObject(self,reason=speech.REASON_FOCUS)
def event_alert(self): if not config.conf["presentation"]["reportHelpBalloons"]: return speech.speakObject(self, reason=controlTypes.REASON_FOCUS) # Ideally, we wouldn't use getBrailleTextForProperties directly. braille.handler.message(braille.getBrailleTextForProperties(name=self.name, role=self.role))
def script_changeItem(self,gesture): gesture.send() if not isScriptWaiting(): api.processPendingEvents() speech.speakObject(self,reason=controlTypes.REASON_FOCUS) braille.handler.handleGainFocus(self)
def script_moveNavigatorObjectToMouse(self,gesture): ui.message(_("Move navigator object to mouse")) obj=api.getMouseObject() api.setNavigatorObject(obj) speech.speakObject(obj)
def script_speakForeground(self,gesture): obj=api.getForegroundObject() if obj: speech.speakObject(obj,reason=speech.REASON_QUERY) obj.speakDescendantObjects()
def event_focusEntered(self): #for some reason, NVDA doesn't execute a focusEntered event for this object, so force it to do so speech.speakObject(self,reason=controlTypes.REASON_FOCUSENTERED)