Separate out mouse events stolen by AxisItem (#1845)
* separate out mouse events on main plot area * work in scenepositions so that detection also works in a layout * added comments/remove debug statements
This commit is contained in:
parent
addb92f592
commit
775f1d629c
@ -1151,7 +1151,7 @@ class AxisItem(GraphicsWidget):
|
||||
pen, p1, p2 = axisSpec
|
||||
p.setPen(pen)
|
||||
p.drawLine(p1, p2)
|
||||
p.translate(0.5,0) ## resolves some damn pixel ambiguity
|
||||
# p.translate(0.5,0) ## resolves some damn pixel ambiguity
|
||||
|
||||
## draw ticks
|
||||
for pen, p1, p2 in tickSpecs:
|
||||
@ -1184,20 +1184,31 @@ class AxisItem(GraphicsWidget):
|
||||
else:
|
||||
self._updateHeight()
|
||||
|
||||
def wheelEvent(self, ev):
|
||||
def wheelEvent(self, event):
|
||||
lv = self.linkedView()
|
||||
if lv is None:
|
||||
return
|
||||
if self.orientation in ['left', 'right']:
|
||||
lv.wheelEvent(ev, axis=1)
|
||||
# Did the event occur inside the linked ViewBox (and not over the axis iteself)?
|
||||
if lv.sceneBoundingRect().contains(event.scenePos()):
|
||||
# pass event to linked ViewBox without marking it as single axis zoom
|
||||
lv.wheelEvent(event)
|
||||
else:
|
||||
lv.wheelEvent(ev, axis=0)
|
||||
ev.accept()
|
||||
# pass event to linked viewbox with appropriate single axis zoom parameter
|
||||
if self.orientation in ['left', 'right']:
|
||||
lv.wheelEvent(event, axis=1)
|
||||
else:
|
||||
lv.wheelEvent(event, axis=0)
|
||||
event.accept()
|
||||
|
||||
def mouseDragEvent(self, event):
|
||||
lv = self.linkedView()
|
||||
if lv is None:
|
||||
return
|
||||
# Did the mouse down event occur inside the linked ViewBox (and not the axis)?
|
||||
if lv.sceneBoundingRect().contains(event.buttonDownScenePos()):
|
||||
# pass event to linked ViewBox without marking it as single axis pan
|
||||
return lv.mouseDragEvent(event)
|
||||
# otherwise pass event to linked viewbox with appropriate single axis parameter
|
||||
if self.orientation in ['left', 'right']:
|
||||
return lv.mouseDragEvent(event, axis=1)
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user