Ejemplo n.º 1
0
    def mousePressEvent(self, event):
        if event.button() == Qt.MiddleButton or event.source(
        ) == Qt.MouseEventSynthesizedByApplication:
            event.ignore()
            return

        canvas.last_z_value += 1
        self.setZValue(canvas.last_z_value)
        self.resetLinesZValue()
        self.m_cursor_moving = False

        if event.button() == Qt.RightButton:
            event.accept()
            canvas.scene.clearSelection()
            self.setSelected(True)
            self.m_mouse_down = False
            return

        elif event.button() == Qt.LeftButton:
            if self.sceneBoundingRect().contains(event.scenePos()):
                self.m_mouse_down = True
            else:
                # FIXME: Check if still valid: Fix a weird Qt behaviour with right-click mouseMove
                self.m_mouse_down = False
                event.ignore()
                return

        else:
            self.m_mouse_down = False

        QGraphicsObject.mousePressEvent(self, event)
Ejemplo n.º 2
0
 def mousePressEvent(self, event):
     if self.shapeItem.path().contains(event.pos()):
         return QGraphicsObject.mousePressEvent(self, event)
     else:
         event.ignore()