Esempio n. 1
0
    def sendEvent(self, event: QEvent) -> None:
        """
        Send an event.

        Args:
            event: The event to send.
        """
        if event.type() == QEvent.Type.FocusOut:
            # Ignored - cannot get focus back reliably :-(
            return

        if isinstance(event, QMouseEvent):
            # `windowPos` is replaced with `localPos` as it has no meaning in offscreen rendering.
            event = QMouseEvent(event.type(), event.localPos(),
                                event.screenPos(), event.button(),
                                event.buttons(), event.modifiers())

        elif isinstance(event, QWheelEvent):
            event = QWheelEvent(event.position(), event.position(),
                                event.pixelDelta(), event.angleDelta(),
                                event.buttons(), event.modifiers(),
                                event.phase(), event.inverted(),
                                event.source())

        self._window.contentItem().forceActiveFocus()
        QCoreApplication.sendEvent(self._window, event)
Esempio n. 2
0
    def sendEvent(self, event: QEvent) -> None:
        """
        Send an event.

        Args:
            event: The event to send.
        """
        QCoreApplication.sendEvent(self._window, event)
        cursor = self._window.cursor()
        if cursor != self._cursor:
            self.cursor_changed.emit(cursor, get_cursor_name(cursor.shape()))
            self._cursor = cursor
Esempio n. 3
0
 def eventFilter(self, editor, event):
     """Handle all sort of special cases.
     """
     if event.type() == QEvent.KeyPress and event.key() in (Qt.Key_Tab,
                                                            Qt.Key_Backtab):
         # Bring focus to parent so tab editing works as expected
         self.parent().setFocus()
         return QCoreApplication.sendEvent(self.parent(), event)
     if event.type() == QEvent.FocusOut:
         # Send event to parent so it gets closed when clicking on an empty area of the table
         return QCoreApplication.sendEvent(self.parent(), event)
     if event.type() == QEvent.ShortcutOverride and event.key(
     ) == Qt.Key_Escape:
         # Close editor so we don't need to escape twice to close the parent SearchBarEditor
         self.parent().closeEditor(editor, QStyledItemDelegate.NoHint)
         return True
     return super().eventFilter(editor, event)
 def eventFilter(self, editor, event):
     if event.type() == QEvent.FocusOut:
         super().eventFilter(editor, event)
         return QCoreApplication.sendEvent(self.parent(), event)
     return super().eventFilter(editor, event)
Esempio n. 5
0
 def sendKbdEvent(self):
     ev = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.NoModifier, 'a')
     QCoreApplication.sendEvent(self.box, ev)