def getMarkerScript(self, gesture, globalMapScripts): func = scriptHandler._getObjScript(self, gesture, globalMapScripts) if func: return func pmList = self.getResults() + self.getQueries() for result in pmList: func = scriptHandler._getObjScript(result, gesture, globalMapScripts) if func: return func func = scriptHandler._getObjScript(self.defaultMarkerScripts, gesture, globalMapScripts) if func: return func return None
def script_sndkey(self, gesture): if os.path.isfile(playset): winsound.PlaySound(sndp, winsound.SND_ASYNC) if os.path.isfile(talkset): ui.message(_('copy')) gesture.send() focus = api.getFocusObject() if not focus: return if focus.windowClassName == 'ConsoleWindowClass': return globalMapScripts = [] globalMaps = [ inputCore.manager.userGestureMap, inputCore.manager.localeGestureMap ] for globalMap in globalMaps: for identifier in gesture.identifiers: globalMapScripts.extend( globalMap.getScriptsForGesture(identifier)) treeInterceptor = focus.treeInterceptor if treeInterceptor and treeInterceptor.isReady: func = scriptHandler._getObjScript(treeInterceptor, gesture, globalMapScripts) if func and (not treeInterceptor.passThrough or getattr( func, "ignoreTreeInterceptorPassThrough", False)): func(treeInterceptor) return
def process_input(self, gesture): log.debug("Evaluating possible gestures.") scripts = [] maps = [ inputCore.manager.userGestureMap, inputCore.manager.localeGestureMap ] log.debug("Found gesture mapping: \r" % maps) log.debug("Enumerating scripts for these maps.") for map in maps: log.debug("Enumerating gestures for map %r" % map) for identifier in gesture.identifiers: log.debug("Enumerating scripts for gesture %r" % identifier) scripts.extend(map.getScriptsForGesture(identifier)) log.debug("Found scripts: %r" % scripts) focus = api.getFocusObject() log.debug("Examining focus: %r" % focus) tree = focus.treeInterceptor log.debug("Examining tree interceptor: %r" % tree) log.debug("Checking tree interceptor state.") if tree and tree.isReady: log.debug( "Tree interceptor in use. Retrieving scripts for the interceptor." ) func = scriptHandler._getObjScript(tree, gesture, scripts) log.debug("Examining object: %r" % func) log.debug("Examining function attributes.") if func and (not tree.passThrough or getattr( func, "ignoreTreeInterceptorPassThrough", False)): log.debug( "This gesture is already handled elsewhere. Executing associated function." ) func(tree) return True log.debug("Nothing associated here. Pass straight to the system.") gesture.send() return False
def process_input(self, gesture): gesture.send() scripts = [] maps = [ inputCore.manager.userGestureMap, inputCore.manager.localeGestureMap ] for map in maps: for identifier in gesture.identifiers: scripts.extend(map.getScriptsForGesture(identifier)) focus = api.getFocusObject() tree = focus.treeInterceptor if tree and tree.isReady: func = scriptHandler._getObjScript(tree, gesture, scripts) if func and (not tree.passThrough or getattr( func, "ignoreTreeInterceptorPassThrough", False)): func(tree) return True return False
def findScript(gesture, searchWebApp=True): global activeWebApp global useInternalBrowser global webAccessEnabled global defaultBrowserScripts focus = api.getFocusObject() if not focus: return None # Import late to avoid circular import. # We need to import this here because this might be the first import of this module # and it might be needed by global maps. import globalCommands globalMapScripts = [] globalMaps = [ inputCore.manager.userGestureMap, inputCore.manager.localeGestureMap ] globalMap = braille.handler.display.gestureMap if globalMap: globalMaps.append(globalMap) for globalMap in globalMaps: for identifier in gesture.identifiers: globalMapScripts.extend(globalMap.getScriptsForGesture(identifier)) # Gesture specific scriptable object. obj = gesture.scriptableObject if obj: func = scriptHandler._getObjScript(obj, gesture, globalMapScripts) if func: return func # Global plugin default scripts. for plugin in globalPluginHandler.runningPlugins: func = scriptHandler._getObjScript(plugin, gesture, globalMapScripts) if func: return func # webApp scripts webApp = focus.getWebApp() if webApp is not None and searchWebApp is True: # Search if a place marker uses this shortcut if webApp.markerManager: func = webApp.markerManager.getMarkerScript( gesture, globalMapScripts) if func: return func func = scriptHandler._getObjScript(webApp.widgetManager, gesture, globalMapScripts) if func: return func activeWidget = getattr(webApp, 'activeWidget', None) if activeWidget is not None: func = scriptHandler._getObjScript(activeWidget, gesture, globalMapScripts) if func: return func func = scriptHandler._getObjScript(webApp, gesture, globalMapScripts) if func: return func ti = webApp.treeInterceptor if hasattr(ti, 'nodeManager') and (useInternalBrowser is True or activeWidget is not None): func = scriptHandler._getObjScript(webApp.presenter, gesture, globalMapScripts) if func: return func func = scriptHandler._getObjScript(ti.nodeManager, gesture, globalMapScripts) if func: return func # App module default scripts. app = focus.appModule if app: # browsers default scripts. if supportWebApp(focus): func = scriptHandler._getObjScript(defaultBrowserScripts, gesture, globalMapScripts) if func: return func func = scriptHandler._getObjScript(app, gesture, globalMapScripts) if func: return func # Tree interceptor level. treeInterceptor = focus.treeInterceptor if treeInterceptor and treeInterceptor.isReady: func = scriptHandler._getObjScript(treeInterceptor, gesture, globalMapScripts) from browseMode import BrowseModeTreeInterceptor if isinstance(treeInterceptor, BrowseModeTreeInterceptor): func = treeInterceptor.getAlternativeScript(gesture, func) if func and (not treeInterceptor.passThrough or getattr( func, "ignoreTreeInterceptorPassThrough", False)) and ( useInternalBrowser is False or getattr(activeWebApp, 'activeWidget', None) is None): return func # NVDAObject level. func = scriptHandler._getObjScript(focus, gesture, globalMapScripts) if func: return func for obj in reversed(api.getFocusAncestors()): func = scriptHandler._getObjScript(obj, gesture, globalMapScripts) if func and getattr(func, 'canPropagate', False): return func # Global commands. func = scriptHandler._getObjScript(globalCommands.commands, gesture, globalMapScripts) if func: return func return None