def mouseReleaseEvent(self, ev): """Handle mouse release events for kinetic dragging end/auto mode.""" if self._dragging: self._dragging = False self.unsetCursor() if self._kineticScrollingEnabled: # kinetic scrolling if self._kineticData.ignoreEvent(ev): return if self._kineticData._state == KineticData.Pressed: self._kineticData._state = KineticData.Steady event1 = QMouseEvent(QEvent.MouseButtonPress, self._kineticData._pressPos, Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) event2 = QMouseEvent(ev) self._kineticData._ignored.append(event1) self._kineticData._ignored.append(event2) QApplication.postEvent(self, event1) QApplication.postEvent(self, event2) elif self._kineticData._state == KineticData.ManualScroll: self._kineticData._state = KineticData.AutoScroll elif self._kineticData._state == KineticData.AutoScroll: self._kineticData._state = KineticData.Stop self._kineticData._speed = QPoint(0, 0) elif self._kineticData._state == KineticData.Stop: self._kineticData._state = KineticData.Steady if self._kineticData._state == KineticData.Steady: self.cursorNeedUpdate.emit(ev.globalPos()) super(KineticScrollArea, self).mouseReleaseEvent(ev)
def mousePressEvent(self, e: QMouseEvent): self.parent().select(self) n = self.node(e.pos()) if n is not None: self.__line = self.__create_line(n) self.__action = Action.CONNECTING if self.__label is not None and self.__label.node() is not n: self.parent().delete_label(self.__label) self.__label = None return if self.__label is not None: self.parent().delete_label(self.__label) self.__label = None if self._resizable: if abs(e.x() - self.width()) < 8 + Block.padding \ and abs(e.y() - self.height()) < 8 + Block.padding \ and self._check_action(Action.RESIZE): self.__origin = e.pos() self.__action = Action.RESIZE return if self._check_action(Action.DRAG): self.__origin = e.pos() self.__action = Action.DRAG
def click(self, pattern='input', native=False): """Click all elements that match the pattern. Uses standard CSS pattern matching: http://www.w3.org/TR/CSS2/selector.html Returns the number of elements clicked """ es = self.find(pattern) for e in es: if native: # get position of element e_pos = e.geometry().center() # scroll to element position self.page().mainFrame().setScrollPosition(e_pos) scr_pos = self.page().mainFrame().scrollPosition() point_to_click = e_pos - scr_pos # create click on absolute coordinates press = QMouseEvent(QMouseEvent.MouseButtonPress, point_to_click, Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) release = QMouseEvent(QMouseEvent.MouseButtonRelease, point_to_click, Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QApplication.postEvent(self, press) QApplication.postEvent(self, release) else: self.click_by_user_event_simulation(e) return len(es)
def mousePressEvent(self, e: QMouseEvent): BlockManager.deselect_all() if e.button() == Qt.LeftButton: self.__moving = True self.__origin = e.pos() self.setCursor(Qt.DragMoveCursor) elif e.button() == Qt.RightButton: self.show_popup(e.pos())
def mousePressEvent(self, event): """Reimplement Qt method""" if event.button() == Qt.MidButton: self.setFocus() event = QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QsciScintilla.mousePressEvent(self, event) QsciScintilla.mouseReleaseEvent(self, event) self.paste() else: QsciScintilla.mousePressEvent(self, event)
def mousePressEvent(self, event): """Reimplement Qt method only on non-linux platforms""" if os.name != 'posix' and event.button() == Qt.MidButton: self.setFocus() event = QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QsciScintilla.mousePressEvent(self, event) QsciScintilla.mouseReleaseEvent(self, event) self.paste() else: QsciScintilla.mousePressEvent(self, event)
def mousePressEvent(self, event): """Reimplement Qt method""" if os.name != 'posix' and event.button() == Qt.MidButton: self.setFocus() event = QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QPlainTextEdit.mousePressEvent(self, event) QPlainTextEdit.mouseReleaseEvent(self, event) self.paste() else: QPlainTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, e: QMouseEvent): if self.__drag: w = self.width() - e.x() if w <= 11: w = 11 if w >= 450: w = 450 self.setFixedWidth(w) elif e.x() <= 12 and 9 <= e.y() <= 31: self.setCursor(Qt.PointingHandCursor) else: self.setCursor(Qt.ArrowCursor)
def mouseMoveEvent(self, e: QMouseEvent): if self.__action == Action.DRAG: dx = e.x() - self.__origin.x() dy = e.y() - self.__origin.y() self.set_pos(self.x() + dx, self.y() + dy) elif self.__action == Action.RESIZE: self.set_size(e.x(), e.y()) else: if self._resizable and self.__corner_path.translated(self.width(), self.height()).contains(e.pos()): self.setCursor(Qt.SizeFDiagCursor) else: self.setCursor(Qt.ArrowCursor)
def strokeMouseFromCenter(self, imgView, start, end, modifier=Qt.NoModifier, numSteps=10): """ Drag the mouse between two coordinates. A modifier can be specified that will be keep pressed default no modifier """ centerPoint = imgView.rect().bottomRight() / 2 startPoint = QPoint(*start) + centerPoint endPoint = QPoint(*end) + centerPoint # Note: Due to the implementation of volumina.EventSwitch.eventFilter(), # mouse events intended for the ImageView MUST go through the viewport. # Move to start move = QMouseEvent(QEvent.MouseMove, startPoint, Qt.NoButton, Qt.NoButton, modifier) QApplication.sendEvent(imgView.viewport(), move) # Press left button press = QMouseEvent(QEvent.MouseButtonPress, startPoint, Qt.LeftButton, Qt.NoButton, modifier) QApplication.sendEvent(imgView.viewport(), press) # Move to end in several steps #numSteps = numSteps for i in range(numSteps): nextPoint = startPoint + (endPoint - startPoint) * (float(i) / numSteps) move = QMouseEvent(QEvent.MouseMove, nextPoint, Qt.NoButton, Qt.NoButton, modifier) QApplication.sendEvent(imgView.viewport(), move) # Move to end move = QMouseEvent(QEvent.MouseMove, endPoint, Qt.NoButton, Qt.NoButton, modifier) QApplication.sendEvent(imgView.viewport(), move) # Release left button release = QMouseEvent(QEvent.MouseButtonRelease, endPoint, Qt.LeftButton, Qt.NoButton, modifier) QApplication.sendEvent(imgView.viewport(), release) # Wait for the gui to catch up QApplication.processEvents() self.waitForViews([imgView])
def mousePressEvent(self, event): """ Select misspelled word after right click otherwise left clik + right click is needed. Originally from John Schember spellchecker """ if event.button() == Qt.RightButton: # Rewrite the mouse event to a left button event so the cursor is # moved to the location of the pointer. event = QMouseEvent(QEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) QtGui.QTextEdit.mousePressEvent(self, event)
def mouseMoveEvent(self, e: QMouseEvent): if self.__action == Action.DRAG: dx = e.x() - self.__origin.x() dy = e.y() - self.__origin.y() self.set_pos(self.x() + dx, self.y() + dy) elif self.__action == Action.RESIZE: self.set_size(e.x(), e.y()) else: if self._resizable and self.__corner_path.translated( self.width(), self.height()).contains(e.pos()): self.setCursor(Qt.SizeFDiagCursor) else: self.setCursor(Qt.ArrowCursor)
def _select_data(self): area = self.widget.areas[0] self.widget.select_area( area, QMouseEvent(QEvent.MouseButtonPress, QPoint(), Qt.LeftButton, Qt.LeftButton, Qt.KeyboardModifiers())) return [0, 4, 6, 7, 11, 17, 19, 21, 22, 24, 26, 39, 40, 43, 44, 46]
def captureEvent(self, watched, event): if self._shouldSaveEvent(event): try: eventstr = event_to_string(event) except KeyError: logger.warn("Don't know how to record event: {}".format( str(event) )) print "Don't know how to record", str(event) else: # Perform a full garbage collection before determining the name of this widget gc.collect() if sip.isdeleted(watched): return timestamp_in_seconds = self._timer.seconds() objname = str(get_fully_qualified_name(watched)) if not ( self._ignore_parent_events and objname.startswith(self._parent_name) ): # Special case: If this is a MouseRelease and we somehow missed the MousePress, # then create a "synthetic" MousePress and insert it immediately before the release if event.type() == QEvent.MouseButtonPress or event.type() == QEvent.MouseButtonDblClick: self._current_observed_mouse_presses.add( event.button() ) elif event.type() == QEvent.MouseButtonRelease: try: self._current_observed_mouse_presses.remove( event.button() ) except KeyError: synthetic_press_event = QMouseEvent( QEvent.MouseButtonPress, event.pos(), event.globalPos(), event.button(), event.buttons(), event.modifiers() ) synthetic_eventstr = event_to_string(synthetic_press_event) self._captured_events.append( (synthetic_eventstr, objname, timestamp_in_seconds) ) self._captured_events.append( (eventstr, objname, timestamp_in_seconds) ) return
def moveMouseFromCenter(self, imgView, coords): centerPoint = imgView.rect().bottomRight() / 2 point = QPoint(*coords) + centerPoint move = QMouseEvent(QEvent.MouseMove, point, Qt.NoButton, Qt.NoButton, Qt.NoModifier) QApplication.postEvent(imgView, move) QApplication.processEvents()
def mousePressEvent(self, event): """ Re-implemented to handle the mouse press event. event: the mouse press event (QMouseEvent) """ if event.button() == Qt.MidButton: text = self.selectedText() # Simulating left mouse button: event = QMouseEvent(QMouseEvent.MouseButtonPress, event.pos(), Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) ConsoleBaseWidget.mousePressEvent(self, event) if self.new_input_line: self.on_new_line() self.insert_text(text) event.accept() else: ConsoleBaseWidget.mousePressEvent(self, event)
def sendEvent(self, type_, arg1, arg2): type_ = type_.lower() if type_ in ('mousedown', 'mouseup', 'mousemove'): eventType = QMouseEvent.Type(QEvent.None) button = Qt.MouseButton(Qt.LeftButton) buttons = Qt.MouseButtons(Qt.LeftButton) if type_ == 'mousedown': eventType = QEvent.MouseButtonPress elif type_ == 'mouseup': eventType = QEvent.MouseButtonRelease elif type_ == 'mousemove': eventType = QEvent.MouseMove button = buttons = Qt.NoButton assert eventType != QEvent.None event = QMouseEvent(eventType, QPoint(arg1, arg2), button, buttons, Qt.NoModifier) QApplication.postEvent(self.m_webPage, event) QApplication.processEvents() return if type_ == 'click': self.sendEvent('mousedown', arg1, arg2) self.sendEvent('mouseup', arg1, arg2)
def mousePressEvent(self, e: QMouseEvent): self.__block.select() n = self._check_nodes(e.pos()) if n is not None: print('Node found') return if e.button() == Qt.LeftButton: if self._resizable: if self._check_corner(e.pos()) and self._check_action(Action.RESIZE): self.__origin = e.pos() self.__action = Action.RESIZE self.setCursor(Qt.SizeFDiagCursor) return if self._check_action(Action.DRAG): self.__origin = e.pos() self.__action = Action.DRAG self.setCursor(Qt.DragMoveCursor)
def handleMouseRelease(self, event): event.ignore() if event.button() != Qt.LeftButton: return if event in self.d.ignoreList: self.d.ignoreList.remove(event) return if self.d.state == FlickablePrivate.Pressed: event.accept() self.d.state = FlickablePrivate.Steady if self.d.target: event1 = QMouseEvent(QEvent.MouseButtonPress, self.d.pressPos, Qt.LeftButton, Qt.LeftButton, Qt.NoModifier) event2 = QMouseEvent(event) self.d.ignoreList.append(event1) self.d.ignoreList.append(event2) QApplication.postEvent(self.d.target, event1) QApplication.postEvent(self.d.target, event2) elif self.d.state == FlickablePrivate.ManualScroll: event.accept() delta = event.pos() - self.d.pressPos if self.d.timeStamp.elapsed() > 100: self.d.timeStamp = QTime.currentTime() self.d.speed = delta - self.d.delta self.d.delta = delta self.d.offset = self.scrollOffset() self.d.pressPos = QPoint(event.pos()) if self.d.speed == QPoint(0, 0): self.d.state = FlickablePrivate.Steady else: self.d.speed /= 4 self.d.state = FlickablePrivate.AutoScroll self.d.ticker.start(20) elif self.d.state == FlickablePrivate.Stop: event.accept() self.d.state = FlickablePrivate.Steady self.d.offset = self.scrollOffset()
def mouseMoveEvent(self, e: QMouseEvent): if self.__action == Action.DRAG: dx = e.x() - self.__origin.x() dy = e.y() - self.__origin.y() self.set_pos(self.x() + dx, self.y() + dy) elif self.__action == Action.RESIZE: self.set_size(e.x(), e.y()) elif self.__action == Action.CONNECTING and self.__line is not None: p = QPoint(e.x() + self.x(), e.y() + self.y()) n = self.parent().get_node(p) if n is not None and n.compatible(self.__line.n1): self.__line.status(True) else: self.__line.status(False) self.__line.update(p) else: n = self.node(e.pos()) if self.__label is None and n is not None: self.__label = self.parent().create_label(self.node_name(n), n) elif self.__label is not None and self.__label.node() is not n and n is not None: self.parent().delete_label(self.__label) self.__label = self.parent().create_label(self.node_name(n), n) elif n is None: self.parent().delete_label(self.__label) self.__label = None
def mousePressEvent(self, e: QMouseEvent): self.__block.select() n = self._check_nodes(e.pos()) if n is not None: print('Node found') return if e.button() == Qt.LeftButton: if self._resizable: if self._check_corner(e.pos()) and self._check_action( Action.RESIZE): self.__origin = e.pos() self.__action = Action.RESIZE self.setCursor(Qt.SizeFDiagCursor) return if self._check_action(Action.DRAG): self.__origin = e.pos() self.__action = Action.DRAG self.setCursor(Qt.DragMoveCursor)
def strokeMouseFromCenter(self, imgView, start, end): """ Drag the mouse between two coordinates. """ centerPoint = imgView.rect().bottomRight() / 2 startPoint = QPoint(*start) + centerPoint endPoint = QPoint(*end) + centerPoint # Move to start move = QMouseEvent(QEvent.MouseMove, startPoint, Qt.NoButton, Qt.NoButton, Qt.NoModifier) QApplication.postEvent(imgView, move) # Press left button press = QMouseEvent(QEvent.MouseButtonPress, startPoint, Qt.LeftButton, Qt.NoButton, Qt.NoModifier) QApplication.postEvent(imgView, press) # Move to end in several steps numSteps = 10 for i in range(numSteps): nextPoint = startPoint + (endPoint - startPoint) * (float(i) / numSteps) move = QMouseEvent(QEvent.MouseMove, nextPoint, Qt.NoButton, Qt.NoButton, Qt.NoModifier) QApplication.postEvent(imgView, move) # Move to end move = QMouseEvent(QEvent.MouseMove, endPoint, Qt.NoButton, Qt.NoButton, Qt.NoModifier) QApplication.postEvent(imgView, move) # Release left button release = QMouseEvent(QEvent.MouseButtonRelease, endPoint, Qt.LeftButton, Qt.NoButton, Qt.NoModifier) QApplication.postEvent(imgView, release) # Wait for the gui to catch up QApplication.processEvents() self.waitForViews([imgView])
def mousePressEvent(self, event): prevIndex = self.model().selectedIndex() newIndex = self.indexAt(event.pos()) super(LayerWidget, self).mousePressEvent(event) # HACK: The first click merely gives focus to the list item without actually passing the event to it. # We'll simulate a mouse click on the item by calling mousePressEvent() and mouseReleaseEvent on the appropriate editor if prevIndex != newIndex and newIndex.row() != -1: layer = self.model().itemData(newIndex)[Qt.EditRole].toPyObject() assert isinstance(layer, Layer) hitWidget = QApplication.widgetAt(event.globalPos()) hitWidgetPos = event.pos() - hitWidget.geometry().topLeft() hitWidgetPress = QMouseEvent(QMouseEvent.MouseButtonPress, hitWidgetPos, event.globalPos(), event.button(), event.buttons(), event.modifiers()) hitWidget.mousePressEvent(hitWidgetPress) hitWidgetRelease = QMouseEvent(QMouseEvent.MouseButtonRelease, hitWidgetPos, event.globalPos(), event.button(), event.buttons(), event.modifiers()) hitWidget.mouseReleaseEvent(hitWidgetRelease)
def mousePressEvent(self, event): """ Makes sure event is forwarded to both base classes. If position of event is within the dropArea of a port a QMouseEvent is sent to the port. See dropArea(). """ dropAreaPort = self.dropAreaPort(event.pos()) if dropAreaPort and dropAreaPort.isDragable(): dropAreaPort.grabMouse() newEvent = QMouseEvent(event.type(), dropAreaPort.mapFromParent(event.pos()), event.button(), event.buttons(), event.modifiers()) QCoreApplication.instance().sendEvent(dropAreaPort, newEvent) else: VispaWidgetOwner.mousePressEvent(self, event) VispaWidget.mousePressEvent(self, event)
def event(self, ev): if self._textedit: if ((ev.type() in (QEvent.MouseButtonPress, QEvent.MouseButtonRelease) and ev.button() == Qt.LeftButton) or (ev.type() == QEvent.MouseMove and ev.buttons() & Qt.LeftButton)): new = QMouseEvent(ev.type(), QPoint(0, ev.y()), ev.button(), ev.buttons(), ev.modifiers()) return QApplication.sendEvent(self._textedit.viewport(), new) elif ev.type() == QEvent.Wheel: return QApplication.sendEvent(self._textedit.viewport(), ev) return super(LineNumberArea, self).event(ev)
def eventFilter(self, watched, event): etype = event.type() if self._current_state == self.DEFAULT_MODE: if event.type() == QEvent.KeyPress: if event.key() == Qt.Key_Control: QApplication.setOverrideCursor(QtCore.Qt.OpenHandCursor) if event.type() == QEvent.KeyRelease: if event.key() == Qt.Key_Control: QApplication.restoreOverrideCursor() if etype == QEvent.MouseButtonPress \ and event.button() == Qt.LeftButton \ and event.modifiers() == Qt.NoModifier \ and self._navIntr.mousePositionValid(watched, event): ### default mode -> maybe draw mode self._current_state = self.MAYBE_DRAW_MODE # event will not be valid to use after this function exits, # so we must make a copy of it instead of just saving the pointer self._lastEvent = QMouseEvent(event.type(), event.pos(), event.globalPos(), event.button(), event.buttons(), event.modifiers()) if self.getColor() == 1: assert self._brushingModel.brushSize == 1, "Wrong brush size %d" % self._brushingModel.brushSize self._current_state = self.DRAW_MODE self.onEntry_draw(watched, self._lastEvent) #self.onMouseMove_draw( watched, event ) self.onExit_draw(watched, event) self._current_state = self.DEFAULT_MODE self.onEntry_default(watched, event) pos = [int(i) for i in self._posModel.cursorPos] pos = [self._posModel.time ] + pos + [self._posModel.channel] #self._dotsController.addNewDot(pos) return True return super(DotInterpreter, self).eventFilter(watched, event)
def propagateEventUnderConnectionWidget(self, connection, event): """ This function propagates an event to one of it's children. If a connection widget is clicked in an area where it does not draw the connection line, the event should be forwarded to the underlying widget if there is such one. However the default behavior of Qt is to propagate the event to the connection's parent. This should be an ConnectableWidgetOwner object. This function is a workaround searching for any child widget at event.pos() which is not the initial connection. If it finds such a widget a new event with correct position in the new widget's own frame is created and sent to the widget. This function calls grabMouse() on the found child. The child should make sure releaseMouse() will be called e.g. in mouseReleaseEvent(). Currently supported events: QEvent.MouseButtonPress, QEvent.MouseButtonDblClick. """ logging.debug("%s: propagateEventUnderConnectionWidget() - %s" % (self.__class__.__name__, str(event.type()))) workspacePos = connection.mapToParent(event.pos()) for child in reversed(self.children()): if not child == connection and isinstance( child, QWidget) and child.geometry().contains(workspacePos): # do not forward event to connections which do not cross the mouse click point, this is important to prevent infinite loop error if isinstance(child, PortConnection ) and not child.belongsToRoute(workspacePos): continue # if event.type() == QEvent.MouseButtonDblClick or \ # event.type() == QEvent.MouseButtonPress or \ # event.type() == QEvent.MouseButtonRelease or \ # event.type() == QEvent.MouseMove or \ # event.type() == QEvent.DragEnter or \ # event.type() == QEvent.Drop: childPos = child.mapFromParent(workspacePos) grandChild = child.childAt(childPos) if grandChild: child = grandChild childPos = child.mapFromParent(childPos) if event.type() == QEvent.MouseButtonPress: child.grabMouse(QCursor(Qt.ClosedHandCursor)) child.setFocus() newEvent = QMouseEvent(event.type(), childPos, event.button(), event.buttons(), event.modifiers()) QCoreApplication.instance().sendEvent(child, newEvent) return True return False
def eventFilter(self, watched, event): etype = event.type() if etype == QEvent.MouseButtonDblClick and self._doubleClickTimer is not None: # On doubleclick, cancel release handler that normally draws the stroke. self._doubleClickTimer.stop() self._doubleClickTimer = None self._current_state = self.DEFAULT_MODE self.onEntry_default(watched, event) if self._current_state == self.DEFAULT_MODE: if etype == QEvent.MouseButtonPress \ and event.button() == Qt.LeftButton \ and event.modifiers() == Qt.NoModifier \ and self._navIntr.mousePositionValid(watched, event): ### default mode -> maybe draw mode self._current_state = self.MAYBE_DRAW_MODE # event will not be valid to use after this function exits, # so we must make a copy of it instead of just saving the pointer self._lastEvent = QMouseEvent(event.type(), event.pos(), event.globalPos(), event.button(), event.buttons(), event.modifiers()) elif self._current_state == self.MAYBE_DRAW_MODE: if etype == QEvent.MouseMove: # navigation interpreter also has to be in # default mode to avoid inconsistencies if self._navIntr.state == self._navIntr.DEFAULT_MODE: ### maybe draw mode -> maybe draw mode self._current_state = self.DRAW_MODE self.onEntry_draw(watched, self._lastEvent) self.onMouseMove_draw(watched, event) return True else: self._navIntr.eventFilter(watched, self._lastEvent) return self._navIntr.eventFilter(watched, event) elif etype == QEvent.MouseButtonDblClick: ### maybe draw mode -> default mode self._current_state = self.DEFAULT_MODE return self._navIntr.eventFilter(watched, event) elif etype == QEvent.MouseButtonRelease: def handleRelease(releaseEvent): self._current_state = self.DRAW_MODE self.onEntry_draw(watched, self._lastEvent) self.onExit_draw(watched, releaseEvent) self._current_state = self.DEFAULT_MODE self.onEntry_default(watched, releaseEvent) # If this event is part of a double-click, we don't really want to handle it. # Typical event sequence is press, release, double-click (not two presses). # Instead of handling this right away, set a timer to do the work. # We'll cancel the timer if we see a double-click event (see above). self._doubleClickTimer = QTimer(self) self._doubleClickTimer.setInterval(200) self._doubleClickTimer.setSingleShot(True) # event will not be valid to use after this function exits, # so we must make a copy of it instead of just saving the pointer eventCopy = QMouseEvent(event.type(), event.pos(), event.button(), event.buttons(), event.modifiers()) self._doubleClickTimer.timeout.connect( partial(handleRelease, eventCopy)) self._doubleClickTimer.start() return True elif self._current_state == self.DRAW_MODE: if etype == QEvent.MouseButtonRelease and event.button( ) == Qt.LeftButton: self.onExit_draw(watched, event) ### draw mode -> default mode self._current_state = self.DEFAULT_MODE self.onEntry_default(watched, event) return True elif etype == QEvent.MouseMove and event.buttons() & Qt.LeftButton: if self._navIntr.mousePositionValid(watched, event): self.onMouseMove_draw(watched, event) return True else: self.onExit_draw(watched, event) ### draw mode -> default mode self._current_state = self.DEFAULT_MODE self.onEntry_default(watched, event) # let the navigation interpreter handle common events return self._navIntr.eventFilter(watched, event)
def mousePressEvent(self, event: QMouseEvent): progress = event.x() / self.width() value = int(progress * self.maximum()) self.setValue(value)
def mousePressEvent(self, e: QMouseEvent): if e.x() <= 12 and 9 <= e.y() <= 31 and e.button() == Qt.LeftButton: self.__drag = True self.repaint() else: self.__drag = False
def mouseMoveEvent(self, event): pos = self.mapToParent(event.pos()) newevent = QMouseEvent(event.type(), pos, event.button(), event.buttons(), event.modifiers()) self.parent().mouseMoveEvent(newevent)
def mousePressEvent(self, event: QtGui.QMouseEvent): self.setMovable(self.tabAt(event.pos()) not in (0, 1)) super().mousePressEvent(event)
def mouseMoveEvent(self, e: QMouseEvent): if self.__moving: dx = e.x() - self.__origin.x() dy = e.y() - self.__origin.y() self.__origin = e.pos() self.translate(dx, dy)
def mouseDoubleClickEvent(self, e: QMouseEvent): BlockManager.deselect_all() if e.button() == Qt.LeftButton: self.__moving = False self.__translation = QPoint() self.translate(0, 0)
def _select_data(self): self.widget.select_area( 1, QMouseEvent(QEvent.MouseButtonPress, QPoint(), Qt.LeftButton, Qt.LeftButton, Qt.KeyboardModifiers())) return [2, 3, 9, 23, 29, 30, 34, 35, 37, 42, 47, 49]
def mouseMoveEvent(self, e: QMouseEvent): self.setCursor(self.get_cursor(e.pos()))
def mousePressEvent(self, e: QMouseEvent): print(self.get_border(e.pos()))