Skip to content

Commit

Permalink
[API] Expose mouse wheel to map tools as QgsMapTool::wheelEvent()
Browse files Browse the repository at this point in the history
  • Loading branch information
Borys Jurgiel committed Mar 30, 2013
1 parent 8299001 commit daeafcc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/gui/qgsmaptool.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmaptool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmaptool.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class QgsMapLayer;
class QgsMapCanvas;
class QKeyEvent;
class QMouseEvent;
class QWheelEvent;
class QgsPoint;
class QgsRectangle;
class QPoint;
Expand Down Expand Up @@ -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 );

Expand Down

0 comments on commit daeafcc

Please sign in to comment.