#TODO: Make signals work properly
def mousePressEvent(self, event):
self.emit(SIGNAL("pressed"), (event))
def mouseReleaseEvent(self, event):
self.emit(SIGNAL("released"), (event))
######
#Assigned via self.connect(self, SIGNAL('pressed'), self.grabCanvas) in __init__
def grabCanvas(self, event):
if event.buttons() == QtCore.Qt.MidButton:
origMode = self.dragMode()
self.setDragMode(self.ScrollHandDrag)
#Send a fake LMB press, TODO: Disable scene's selection of objects
QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.KeyboardModifiers())
#Add a handler to catch the mouse up event
def revert(event):
self.setDragMode(origMode)
self.disconnect(self, SIGNAL("released"), revert)
self.connect(self, SIGNAL("released"), revert)
#TODO: Make signals work properly
def mousePressEvent(self, event):
self.emit(SIGNAL("pressed"), (event))
QtGui.QGraphicsView.mousePressEvent(self, event)
def mouseReleaseEvent(self, event):
self.emit(SIGNAL("released"), (event))
QtGui.QGraphicsView.mouseReleaseEvent(self, event)
######
#Assigned via self.connect(self, SIGNAL('pressed'), self.grabCanvas) in __init__
def grabCanvas(self, event):
if event.buttons() == QtCore.Qt.MidButton:
origMode = self.dragMode()
self.setDragMode(self.ScrollHandDrag)
#Send a fake LMB press, TODO: Disable scene's selection of objects
fake_event = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress, event.pos(),
QtCore.Qt.LeftButton, QtCore.Qt.LeftButton, QtCore.Qt.KeyboardModifiers())
QtGui.QGraphicsView.mousePressEvent(self, fake_event)
#Add a handler to catch the mouse up event
def revert(event):
self.setDragMode(origMode)
self.disconnect(self, SIGNAL("released"), revert)
self.connect(self, SIGNAL("released"), revert)
To copy to clipboard, switch view to plain text mode
Bookmarks