Module inputCore :: Class GlobalGestureMap
[hide private]
[frames] | no frames]

Class GlobalGestureMap

source code

object --+
         |
        GlobalGestureMap

Maps gestures to scripts anywhere in NVDA. This is used to allow users and locales to bind gestures in addition to those bound by individual scriptable objects. Map entries will most often be loaded from a file using the load method. See that method for details of the file format.

Instance Methods [hide private]
 
__init__(self, entries=None)
Constructor.
source code
 
clear(self)
Clear this map.
source code
 
add(self, gesture, module, className, script, replace=False)
Add a gesture mapping.
source code
 
load(self, filename)
Load map entries from a file.
source code
 
update(self, entries)
Add multiple map entries.
source code
generator of (class, str)
getScriptsForGesture(self, gesture)
Get the scripts associated with a particular gesture.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, entries=None)
(Constructor)

source code 

Constructor.

Parameters:
  • entries (mapping of str to mapping) - Initial entries to add; see update for the format.
Overrides: object.__init__

add(self, gesture, module, className, script, replace=False)

source code 

Add a gesture mapping.

Parameters:
  • gesture (str) - The gesture identifier.
  • module (str) - The name of the Python module containing the target script.
  • className (str) - The name of the class in module containing the target script.
  • script (str) - The name of the target script or None to unbind the gesture for this class.
  • replace (boolean) - if true replaces all existing bindings for this gesture with the given script, otherwise only appends this binding.

load(self, filename)

source code 

Load map entries from a file. The file is an ini file. Each section contains entries for a particular scriptable object class. The section name must be the full Python module and class name. The key of each entry is the script name and the value is a comma separated list of one or more gestures. If the script name is "None", the gesture will be unbound for this class. For example, the following binds the "a" key to move to the next heading in virtual buffers and removes the default "h" binding:

       [virtualBuffers.VirtualBuffer]
       nextHeading = kb:a
       None = kb:h
Parameters:
  • filename - The name of the file to load.

update(self, entries)

source code 

Add multiple map entries. entries must be a mapping of mappings. Each inner mapping contains entries for a particular scriptable object class. The key in the outer mapping must be the full Python module and class name. The key of each entry in the inner mappings is the script name and the value is a list of one or more gestures. If the script name is None, the gesture will be unbound for this class. For example, the following binds the "a" key to move to the next heading in virtual buffers and removes the default "h" binding:

       {
               "virtualBuffers.VirtualBuffer": {
                       "nextHeading": "kb:a",
                       None: "kb:h",
               }
       }
Parameters:
  • entries (mapping of str to mapping) - The items to add.

getScriptsForGesture(self, gesture)

source code 

Get the scripts associated with a particular gesture.

Parameters:
  • gesture (str) - The gesture identifier.
Returns: generator of (class, str)
The Python class and script name for each script; the script name may be None indicating that the gesture should be unbound for this class.