diff --git a/python/gui/qgsmaptool.sip b/python/gui/qgsmaptool.sip index 892117351c9e..47b658267ed8 100644 --- a/python/gui/qgsmaptool.sip +++ b/python/gui/qgsmaptool.sip @@ -47,6 +47,10 @@ class QgsMapTool : QObject //! Mouse release event for overriding. Default implementation does nothing. virtual void canvasReleaseEvent( QMouseEvent * e ); + //! Mouse wheel event for overriding. Default implementation does nothing. + //! Added in version 2.0 + virtual void wheelEvent( QWheelEvent * e ); + //! Key event for overriding. Default implementation does nothing. virtual void keyPressEvent( QKeyEvent* e ); diff --git a/src/gui/qgsmapcanvas.cpp b/src/gui/qgsmapcanvas.cpp index f8b57764381e..054b5add357e 100644 --- a/src/gui/qgsmapcanvas.cpp +++ b/src/gui/qgsmapcanvas.cpp @@ -1094,6 +1094,11 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e ) return; } + if ( mMapTool ) + { + mMapTool->wheelEvent( e ); + } + if ( QgsApplication::keyboardModifiers() ) { // leave the wheel for map tools if any modifier pressed diff --git a/src/gui/qgsmaptool.cpp b/src/gui/qgsmaptool.cpp index 6ca3603d189c..9cc529f75362 100644 --- a/src/gui/qgsmaptool.cpp +++ b/src/gui/qgsmaptool.cpp @@ -131,6 +131,11 @@ void QgsMapTool::canvasReleaseEvent( QMouseEvent *e ) Q_UNUSED( e ); } +void QgsMapTool::wheelEvent( QWheelEvent *e ) +{ + Q_UNUSED( e ); +} + void QgsMapTool::keyPressEvent( QKeyEvent *e ) { Q_UNUSED( e ); diff --git a/src/gui/qgsmaptool.h b/src/gui/qgsmaptool.h index 5807d98cc98b..d6c276064183 100644 --- a/src/gui/qgsmaptool.h +++ b/src/gui/qgsmaptool.h @@ -30,6 +30,7 @@ class QgsMapLayer; class QgsMapCanvas; class QKeyEvent; class QMouseEvent; +class QWheelEvent; class QgsPoint; class QgsRectangle; class QPoint; @@ -61,6 +62,10 @@ class GUI_EXPORT QgsMapTool : public QObject //! Mouse release event for overriding. Default implementation does nothing. virtual void canvasReleaseEvent( QMouseEvent * e ); + //! Mouse wheel event for overriding. Default implementation does nothing. + //! Added in version 2.0 + virtual void wheelEvent ( QWheelEvent* e ); + //! Key event for overriding. Default implementation does nothing. virtual void keyPressEvent( QKeyEvent* e );