def mousePressEvent(self, evt: QGraphicsSceneMouseEvent): if evt.button() == Qt.LeftButton: pos = (evt.scenePos().x(), evt.scenePos().y()) self.relative_pos = (pos[0] - self.x(), pos[1] - self.y()) self.port_clicked.emit(self) elif evt.button() == Qt.RightButton: pass elif evt.button() == Qt.MidButton: pass
def mousePressEvent(self, evt: QGraphicsSceneMouseEvent): if evt.button() == Qt.LeftButton: pos = (evt.scenePos().x(), evt.scenePos().y()) self.relative_pos = (pos[0] - self.x(), pos[1] - self.y()) if not evt.modifiers() == Qt.ControlModifier: self.scene().signal_clear_selection.emit() self.scene().select_item(self) self.color = COLOR_SELECTED elif evt.button() == Qt.RightButton: pass elif evt.button() == Qt.MidButton: pass
def buttonPressEvent(self, event: QtWidgets.QGraphicsSceneMouseEvent, index: int) -> None: # right mouse button opens the mask menu if event.button() == QtCore.Qt.RightButton or index >= len(self.types): # open the menu if it is not open already if not self.mask_handler.mask_edit_window or not self.mask_handler.mask_edit_window.isVisible(): self.mask_handler.mask_edit_window = MaskEditor(self.mask_handler, self.mask_handler.mask_file) self.mask_handler.mask_edit_window.show() else: self.mask_handler.mask_edit_window.raise_() # select this mask type in the menu self.mask_handler.mask_edit_window.setMaskType(self.types[index] if index < len(self.types) else None) # a left click selects this type elif event.button() == QtCore.Qt.LeftButton: # select this mask type self.selectType(index)