Skip to content
Permalink
Browse files

[API] Expose mouse wheel to map tools as QgsMapTool::wheelEvent()

  • Loading branch information
Borys Jurgiel
Borys Jurgiel committed Mar 30, 2013
1 parent 8299001 commit daeafccd490a7696db0cdab0116c031d2ddaaf53
Showing with 19 additions and 0 deletions.
  1. +4 −0 python/gui/qgsmaptool.sip
  2. +5 −0 src/gui/qgsmapcanvas.cpp
  3. +5 −0 src/gui/qgsmaptool.cpp
  4. +5 −0 src/gui/qgsmaptool.h
@@ -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 );

@@ -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
@@ -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 );
@@ -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 );

0 comments on commit daeafcc

Please sign in to comment.
You can’t perform that action at this time.