def __makeKeyEvent(self, measure_editor: BaseMeasureEditor,
                    evt: QtGui.QKeyEvent) -> QtGui.QKeyEvent:
     measure_evt = QtGui.QKeyEvent(evt.type(), evt.key(), evt.modifiers(),
                                   evt.nativeScanCode(),
                                   evt.nativeVirtualKey(),
                                   evt.nativeModifiers(), evt.text(),
                                   evt.isAutoRepeat(), evt.count())
     measure_evt.setAccepted(False)
     return measure_evt
Beispiel #2
0
 def __init__(self, key_event: QtGui.QKeyEvent):
     if key_event is None:
         self.key = None
         self.char = ''
         self.count = 0
         self.modifiers = QtCore.Qt.NoModifier
     else:
         self.key = key_event.key()
         self.char = key_event.text()
         self.count = key_event.count()
         self.modifiers = key_event.modifiers()
Beispiel #3
0
 def keyPressEvent(self, event: QtGui.QKeyEvent):
     """Bugfix, disables SHIFT+RETURN misbehaviour."""
     if (event.key() == QtCore.Qt.Key_Enter or event.key() == 16777220) and \
        ((event.modifiers() & QtCore.Qt.ShiftModifier) == QtCore.Qt.ShiftModifier):
         # clone object but without shift
         # current modifiers & all possible modifiers, but SHIFT,ALT,CTRL
         event = QtGui.QKeyEvent(
             event.type(), event.key(),
             event.modifiers() & QtCore.Qt.MetaModifier
             & QtCore.Qt.KeypadModifier, event.text(), event.isAutoRepeat(),
             event.count())
     super().keyPressEvent(event)
Beispiel #4
0
    def keyPressEvent(self, event: QKeyEvent):  # pylint: disable=C0103
        """_summary_

        Args:
            event (QKeyEvent): _description_
        """
        if event.key() == Qt.Key_Backspace:
            cur = self.textCursor()
            cur.setPosition(cur.position() - event.count(), QTextCursor.KeepAnchor)
        if not (event.key() in [Qt.Key_C, Qt.Key_Z] and \
                event.modifiers() & Qt.ControlModifier) and \
                GTextEditor.__has_marker(self.textCursor().selectedText()):
            event.ignore()
            return None
        return super().keyPressEvent(event)