def mousePressEvent(self, ev: QtGui.QMouseEvent): if self._mimetype == "GIF" and ev.button() == QtCore.Qt.LeftButton: ev.accept() self._toggle_movie_play() else: # If it's a right click or otherwise, pass it on ev.ignore()
def mouseReleaseEvent(self, event_data: QMouseEvent): if self._ignoring_mouse_events: return if 0 <= event_data.x() <= self.width() and 0 <= event_data.y( ) <= self.height(): event_data.accept() self.set_checked(not self.is_checked)
def mousePressEvent(self, e: QMouseEvent): if e.buttons() & (Qt.RightButton | Qt.LeftButton): print("mousePressEvent in Item...") self.__m_lastMouseButton = self.__cloneMouseEvent(e) self.__m_lastMouseButton.ignore() e.accept() self.update()
def mouseMoveEvent(self, e: QMouseEvent): if e.buttons() & (Qt.RightButton | Qt.LeftButton): qDebug("mouseMoveEvent in Item...") self.__m_lastMouseMove = self.__cloneMouseEvent(e) self.__m_lastMouseMove.ignore() e.accept() self.update()
def mouseReleaseEvent(self, event: QMouseEvent): """ Handle mouse release, ending viewport drag. """ if event.button() == Qt.LeftButton: self.setCursor(Qt.ArrowCursor) event.accept() self._is_mouse_pressed = False
def mouseMoveEvent(self, event: QMouseEvent): """ Handle mouse move, moving the target view port to cursor position in target scene when mouse is pressed. """ if self._is_mouse_pressed: self._target_view.centerOn( self.map_event_pos_to_target_scene_pos(event.pos())) event.accept()
def mouseMoveEvent(self, event: QMouseEvent): if self.is_dragged(): pos: QPoint = event.pos() delta: QPoint = self.last_drag_pos - pos self.last_drag_pos = pos self.camera.translate(-delta) self.camera.transformed.emit() event.accept()
def mouseReleaseEvent(self, event: gui.QMouseEvent): if event.button() != core.Qt.LeftButton: event.ignore() return event.accept() progress = event.x() / self.width() self.setValue(int(progress * self.maximum())) if self._on_click: self._on_click(event)
def mousePressEvent(self, event: QMouseEvent): """ Handle mouse press, moving the target view port to cursor position in target scene. """ if event.button() == Qt.LeftButton: self._is_mouse_pressed = True self.setCursor(Qt.ClosedHandCursor) self._target_view.centerOn( self.map_event_pos_to_target_scene_pos(event.pos())) event.accept()
def mousePressEvent(self, event: QtGui.QMouseEvent): pos = QtCore.QRect() pos.setX(int(event.localPos().x())) pos.setY(int(event.localPos().y())) pos.setHeight(100) pos.setWidth(400) id = self._next_id("Text Box") item = PageItem(id, pos) self._add_item(item) event.accept()
def mouseMoveEvent(self, event: QtGui.QMouseEvent): if event.buttons() == QtCore.Qt.LeftButton: diff = QtGui.QVector2D(event.localPos()) - self.m_mousePos self.m_mousePos = QtGui.QVector2D(event.localPos()) angle = diff.length() / 2.0 axis = QtGui.QVector3D(diff.y(), diff.x(), 0.0) self.m_viewRotation = QtGui.QQuaternion.fromAxisAndAngle( axis, angle) * self.m_viewRotation self.update() event.accept()
def mousePressEvent(self, e: QtGui.QMouseEvent): self.position = QPoint(e.globalX() - self.geometry().x(), e.globalY() - self.geometry().y()) if not self.m_isEditing: return if not self.m_infocus: return if not e.buttons() and QtCore.Qt.LeftButton: self.setCursorShape(e.pos()) return if e.button() == QtCore.Qt.RightButton: self.popupShow(e.pos()) e.accept()
def mousePressEvent(self, ev: QtGui.QMouseEvent): if ev.button() == QtCore.Qt.LeftButton: self.drag_offset = ev.globalPos() - self.parent().mapToGlobal(self.pos()) self.setMouseTracking(True) ev.accept() elif ev.button() == QtCore.Qt.RightButton: """Open context dialog""" dialog = QtWidgets.QMenu("Actions") dialog.setParent(self.parent()) dialog.setStyleSheet(""" QMenu {{ background-color: {}; }} QMenu::item {{ background-color: transparent; }} QMenu::item:selected {{ background-color: {}; color: {}; }} """.format(PAGE_ITEM_MENU_BG, PAGE_ITEM_MENU_SELECTED, DEFAULT_ITEM_TEXT_COLOR)) close_option = QtWidgets.QAction("Remove", dialog) close_option.setStatusTip("Delete this text box and all its contents") close_option.triggered.connect(self.deleteLater) raise_option = QtWidgets.QAction("Bring To Front", dialog) # Using parent() (and especially parent().parent()) is extremely fragile. # TODO make more clear cut ways of retrieving the element we want raise_option.triggered.connect(lambda: self.raised.emit(self.z_index)) lower_option = QtWidgets.QAction("Send To Back", dialog) lower_option.triggered.connect(lambda: self.lowered.emit(self.z_index)) rename_option = QtWidgets.QAction("Rename", dialog) rename_option.triggered.connect(self._rename_dialog) cancel_option = QtWidgets.QAction("Cancel", dialog) # Image specific options if self._type == "image": edit_image_action = QtWidgets.QAction("Edit Image", dialog) dialog.addAction(raise_option) dialog.addAction(lower_option) dialog.addAction(rename_option) dialog.addSeparator() dialog.addAction(close_option) dialog.addSeparator() if self._type == "image": dialog.addAction(edit_image_action) dialog.addSeparator() dialog.addAction(cancel_option) dialog.triggered.connect(lambda _: dialog.deleteLater()) pos = self.mapToGlobal(ev.pos()) dialog.popup(self.parent().parent().mapFromGlobal(pos)) ev.accept()
def mouseDoubleClickEvent(self, event: QMouseEvent) -> None: if event.button() == Qt.LeftButton: chartWindow = InteractiveChartWindow( self) # needs a parent to be kept alive # Open widget with plot chart = copyChart(self.chart()) iView = InteractiveChartView(chart=chart, setInWindow=True) iView.enableKeySequences(False) iView.setRenderHints(self.renderHints()) chartWindow.setAttribute(Qt.WA_DeleteOnClose, True) chartWindow.setCentralWidget( iView) # window takes ownership of view chartWindow.resize(500, 500) chartWindow.show() event.accept() super().mouseDoubleClickEvent(event)
def mousePressEvent(self, event: QtGui.QMouseEvent) -> None: option = QtWidgets.QStyleOptionSlider() self.initStyleOption(option) groove = self.style().subControlRect( QtWidgets.QStyle.CC_Slider, option, QtWidgets.QStyle.SC_SliderGroove, self ) handle = self.style().subControlRect( QtWidgets.QStyle.CC_Slider, option, QtWidgets.QStyle.SC_SliderHandle, self ) pos = self.style().sliderPositionFromValue( self.minimum(), self.maximum(), self.value2(), groove.width() ) handle.moveCenter(QtCore.QPoint(pos, handle.center().y())) if handle.contains(event.pos()): event.accept() self._pressed = True self.setSliderDown(True) else: super().mousePressEvent(event)
def mouseMoveEvent(self, event: QMouseEvent) -> None: if self._panEnabled and self._panOn: offset = event.pos() - self._mousePressEventPos self.chart().scroll(-offset.x(), offset.y()) self._mousePressEventPos = event.pos() event.accept() elif self._chartIsSet and self._positionTrackerEnabled: metrics = QFontMetrics(self._coordX.font()) xVal = self.chart().mapToValue(event.pos()).x() yVal = self.chart().mapToValue(event.pos()).y() # if self.chart().axisX().type() == QtCharts.QAbstractAxis.AxisTypeDateTime: xText: str = 'X: {}'.format( computeAxisValue(self.chart().axisX(), xVal)) yText: str = 'Y: {}'.format( computeAxisValue(self.chart().axisY(), yVal)) xSize = metrics.width(xText, -1) ySize = metrics.width(yText, -1) totSize = xSize + ySize self._updateMouseTrackerPosition(xOffset=(totSize // 2)) self._coordX.setText(xText) self._coordY.setText(yText) super().mouseMoveEvent(event)
def mousePressEvent(self, e: QtGui.QMouseEvent): super().mousePressEvent(e) G_FORMAT_SIGNALLER.active_font_changed.emit(self.get_format().font()) # in case we selected different text e.accept() # Don't propagate the click even to parent (don't want to show two context menus)
def mousePressEvent(self, event: QMouseEvent): self.set_focus() self._update_value_by_x(event.x()) event.accept()
def mouseMoveEvent(self, e: QMouseEvent): # print("mouseMoveEvent in Item...") self.__m_lastMouseMove = self.__cloneMouseEvent(e) self.__m_lastMouseMove.ignore() e.accept() self.update()
def mousePressEvent(self, ev: QtGui.QMouseEvent) -> None: if ev.button() == QtCore.Qt.LeftButton: self.setValue(self.minimum() + (self.maximum() - self.minimum()) * ev.x() // self.width()) ev.accept() super().mousePressEvent(ev)
def mousePressEvent(self, event: QtGui.QMouseEvent): if event.button() == QtCore.Qt.LeftButton: self.moveSlider(event.x()) event.accept() else: QtWidgets.QWidget.mousePressEvent(event)
def mouseReleaseEvent(self, event: QMouseEvent) -> None: if event.button() == Qt.RightButton: self._create_menu(event) event.accept()
def mouseReleaseEvent(self, e: QMouseEvent): self.__m_lastMouseButton = self.__cloneMouseEvent(e) self.__m_lastMouseButton.ignore() e.accept() self.update()
def mouseReleaseEvent(self, event: QtGui.QMouseEvent): self.setMouseTracking(False) event.accept()
def mouseReleaseEvent(self, e: QMouseEvent): qDebug("mouseReleaseEvent in Item...") self.__m_lastMouseButton = self.__cloneMouseEvent(e) self.__m_lastMouseButton.ignore() e.accept() self.update()
def mouseReleaseEvent(self, event: QMouseEvent): self.last_drag_pos = None event.accept()
def mousePressEvent(self, event: QMouseEvent): if event.button() == Qt.LeftButton: self.last_drag_pos = event.pos() event.accept()
def mouseMoveEvent(self, event: QMouseEvent): self._update_value_by_x(event.x()) event.accept()
def mouseDoubleClickEvent(self, event: QMouseEvent): self._value_line_edit.selectAll() event.accept()
def mouseMoveEvent(self, e: QMouseEvent): self.__m_lastMouseMove = self.__cloneMouseEvent(e) self.__m_lastMouseMove.ignore() e.accept() self.update()