Skip to content

Commit

Permalink
Fix MDI area so that when scrolling over a sub-window, the scrolling …
Browse files Browse the repository at this point in the history
…action does not also apply to the area as a whole.
  • Loading branch information
astrofrog committed Jan 16, 2019
1 parent 39333e9 commit 99cd02f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions glue/app/qt/mdi_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,38 @@ def paintEvent(self, event):
painter.drawText(rect, Qt.AlignHCenter | Qt.AlignVCenter,
"Drag Data To Plot")

def wheelEvent(self, event):

# NOTE: when a scroll wheel event happens on top of a GlueMdiSubWindow,
# we need to ignore it in GlueMdiArea to prevent the canvas from moving
# around. I couldn't find a clean way to do this with events, so instead
# in GlueMdiSubWindow I set a flag, _wheel_event, to indicate that a
# wheel event has happened in a subwindow, which means the next time
# the GlueMdiArea.wheelEvent gets called, we should ignore the wheel
# event.

any_subwindow_wheel = False

for window in self.subWindowList():
if getattr(window, '_wheel_event', None):
any_subwindow_wheel = True
window._wheel_event = None

if any_subwindow_wheel:
event.ignore()
return

super(GlueMdiArea, self).wheelEvent(event)


class GlueMdiSubWindow(QtWidgets.QMdiSubWindow):
closed = QtCore.Signal()

def wheelEvent(self, event):
# See NOTE in GlueMdiArea.wheelEvent
self._wheel_event = True
super(GlueMdiSubWindow, self).wheelEvent(event)

def closeEvent(self, event):
super(GlueMdiSubWindow, self).closeEvent(event)
self.closed.emit()

0 comments on commit 99cd02f

Please sign in to comment.