11# A part of NonVisual Desktop Access (NVDA)
2- # Copyright (C) 2007-2022 NV Access Limited, Babbage B.V., Julien Cochuyt
2+ # Copyright (C) 2007-2022 NV Access Limited, Babbage B.V., Julien Cochuyt, Leonard de Ruijter
33# This file is covered by the GNU General Public License.
44# See the file COPYING for more details.
55
88 Optional ,
99 Iterator ,
1010 List ,
11- Set ,
1211)
1312import time
1413import weakref
@@ -49,8 +48,13 @@ def _makeKbEmulateScript(scriptName):
4948def _getObjScript (
5049 obj : "NVDAObjects.NVDAObject" ,
5150 gesture : "inputCore.InputGesture" ,
52- globalMapScripts : Set [ _ScriptFunctionT ],
51+ globalMapScripts : List [ inputCore . InputGestureScriptT ],
5352) -> Optional [_ScriptFunctionT ]:
53+ """
54+ @param globalMapScripts: An ordered list of scripts.
55+ The list is ordered by resolution priority,
56+ the first map in the list should be used to resolve the script first.
57+ """
5458 # Search the scripts from the global gesture maps.
5559 for cls , scriptName in globalMapScripts :
5660 if isinstance (obj , cls ):
@@ -72,15 +76,20 @@ def _getObjScript(
7276 log .exception ()
7377
7478
75- def getGlobalMapScripts (gesture : "inputCore.InputGesture" ) -> Set [_ScriptFunctionT ]:
76- globalMapScripts : Set [_ScriptFunctionT ] = set ()
79+ def getGlobalMapScripts (gesture : "inputCore.InputGesture" ) -> List [inputCore .InputGestureScriptT ]:
80+ """
81+ @returns: An ordered list of scripts.
82+ The list is ordered by resolution priority,
83+ the first map in the list should be used to resolve scripts first.
84+ """
85+ globalMapScripts : List [inputCore .InputGestureScriptT ] = []
7786 globalMaps = [inputCore .manager .userGestureMap , inputCore .manager .localeGestureMap ]
7887 globalMap = braille .handler .display .gestureMap if braille .handler and braille .handler .display else None
7988 if globalMap :
8089 globalMaps .append (globalMap )
8190 for globalMap in globalMaps :
8291 for identifier in gesture .normalizedIdentifiers :
83- globalMapScripts .update (globalMap .getScriptsForGesture (identifier ))
92+ globalMapScripts .extend (globalMap .getScriptsForGesture (identifier ))
8493 return globalMapScripts
8594
8695
0 commit comments