Skip to content

Commit daeafcc

Browse files
author
Borys Jurgiel
committed
[API] Expose mouse wheel to map tools as QgsMapTool::wheelEvent()
1 parent 8299001 commit daeafcc

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

python/gui/qgsmaptool.sip

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class QgsMapTool : QObject
4747
//! Mouse release event for overriding. Default implementation does nothing.
4848
virtual void canvasReleaseEvent( QMouseEvent * e );
4949

50+
//! Mouse wheel event for overriding. Default implementation does nothing.
51+
//! Added in version 2.0
52+
virtual void wheelEvent( QWheelEvent * e );
53+
5054
//! Key event for overriding. Default implementation does nothing.
5155
virtual void keyPressEvent( QKeyEvent* e );
5256

src/gui/qgsmapcanvas.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,11 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
10941094
return;
10951095
}
10961096

1097+
if ( mMapTool )
1098+
{
1099+
mMapTool->wheelEvent( e );
1100+
}
1101+
10971102
if ( QgsApplication::keyboardModifiers() )
10981103
{
10991104
// leave the wheel for map tools if any modifier pressed

src/gui/qgsmaptool.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ void QgsMapTool::canvasReleaseEvent( QMouseEvent *e )
131131
Q_UNUSED( e );
132132
}
133133

134+
void QgsMapTool::wheelEvent( QWheelEvent *e )
135+
{
136+
Q_UNUSED( e );
137+
}
138+
134139
void QgsMapTool::keyPressEvent( QKeyEvent *e )
135140
{
136141
Q_UNUSED( e );

src/gui/qgsmaptool.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class QgsMapLayer;
3030
class QgsMapCanvas;
3131
class QKeyEvent;
3232
class QMouseEvent;
33+
class QWheelEvent;
3334
class QgsPoint;
3435
class QgsRectangle;
3536
class QPoint;
@@ -61,6 +62,10 @@ class GUI_EXPORT QgsMapTool : public QObject
6162
//! Mouse release event for overriding. Default implementation does nothing.
6263
virtual void canvasReleaseEvent( QMouseEvent * e );
6364

65+
//! Mouse wheel event for overriding. Default implementation does nothing.
66+
//! Added in version 2.0
67+
virtual void wheelEvent ( QWheelEvent* e );
68+
6469
//! Key event for overriding. Default implementation does nothing.
6570
virtual void keyPressEvent( QKeyEvent* e );
6671

0 commit comments

Comments
 (0)