Beispiel #1
0
def _checkDuplicates(keystring, modifiers, type_):
    for keyBinding in _plainKeyBindings + _modifiedKeyBindings:
        if (_testModifiers(keyBinding.modifiers, modifiers)
                and _testMatchString(keyBinding, keystring, type_)):
            raise avg.Exception(
                'Key binding keystring=%s modifiers=%s type=%s '
                'already defined' % (keystring, modifiers, type_))
Beispiel #2
0
    def _setupInstance(self):
        import libavg.app

        if libavg.app.instance is not None:
            raise avg.Exception('%s has been already instantiated' %
                                self.__class__.__name__)

        libavg.app.instance = self
Beispiel #3
0
def _checkDuplicates(keyBinding):
    for oldBinding in _keyBindings:
        if (oldBinding.type == keyBinding.type and
                oldBinding.scancode == keyBinding.scancode and
                oldBinding.keyname == keyBinding.keyname and
                oldBinding.text == keyBinding.text and
                _testModifiers(oldBinding.modifiers, keyBinding.modifiers)):
            raise avg.Exception('Key binding scancode=%s keyname=%s text=%s modifiers=%s'
                    ' already defined' % (keyBinding.scancode, keyBinding.keyname,
                    keyBinding.text, keyBinding.modifiers))
Beispiel #4
0
def _bindKey(scancode, keyname, text, handler, help, modifiers, type_):
    err = False
    if scancode is not None:
        if keyname is not None or text is not None:
            err = True
    if keyname is not None:
        if scancode is not None or text is not None:
            err = True
    if text is not None:
        if scancode is not None or keyname is not None:
            err = True
    if err:
        raise avg.Exception(
                "Binding a key requires exactly one of scancode, keyname or text.")
    keyBinding = _KeyBinding(scancode, keyname, text, handler, help, modifiers, type_)
    _checkDuplicates(keyBinding)

    _keyBindings.append(keyBinding)
    publisher.notifyUpdate()
Beispiel #5
0
 def _verifyInitialEvent(self, initialEvent, coordSysNode):
     if initialEvent is not None:
         if not(initialEvent.contact.isNodeInTargets(coordSysNode)):
             raise avg.Exception("Gestures with an initialEvent must have coordSysNode set to a node under the event.")