diff options
Diffstat (limited to 'silx/gui/plot/PlotInteraction.py')
-rw-r--r-- | silx/gui/plot/PlotInteraction.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/silx/gui/plot/PlotInteraction.py b/silx/gui/plot/PlotInteraction.py index d182a49..cfe140b 100644 --- a/silx/gui/plot/PlotInteraction.py +++ b/silx/gui/plot/PlotInteraction.py @@ -1604,6 +1604,8 @@ class DrawSelectMode(FocusManager): def __init__(self, plot, shape, label, color, width): eventHandlerClass = _DRAW_MODES[shape] + self._pan = Pan(plot) + self._panStart = None parameters = { 'shape': shape, 'label': label, @@ -1614,6 +1616,23 @@ class DrawSelectMode(FocusManager): ItemsInteractionForCombo(plot), eventHandlerClass(plot, parameters))) + def handleEvent(self, eventName, *args, **kwargs): + # Hack to add pan interaction to select-draw + # See issue Refactor PlotWidget interaction #3292 + if eventName == 'press' and args[2] == MIDDLE_BTN: + self._panStart = args[:2] + self._pan.beginDrag(*args) + return # Consume middle click events + elif eventName == 'release' and args[2] == MIDDLE_BTN: + self._panStart = None + self._pan.endDrag(self._panStart, args[:2], MIDDLE_BTN) + return # Consume middle click events + elif self._panStart is not None and eventName == 'move': + x, y = args[:2] + self._pan.drag(x, y, MIDDLE_BTN) + + super().handleEvent(eventName, *args, **kwargs) + def getDescription(self): """Returns the dict describing this interactive mode""" params = self.eventHandlers[1].parameters.copy() |