Index: src/gui/qgsmaptoolpan.cpp =================================================================== --- src/gui/qgsmaptoolpan.cpp (revision 12391) +++ src/gui/qgsmaptoolpan.cpp (working copy) @@ -17,6 +17,7 @@ #include "qgsmaptoolpan.h" #include "qgsmapcanvas.h" #include "qgscursors.h" +#include "qgsmaptopixel.h" #include #include #include @@ -34,8 +35,12 @@ void QgsMapToolPan::canvasMoveEvent( QMouseEvent * e ) { - if ( mDragging && ( e->buttons() & Qt::LeftButton ) ) + if ( ( e->buttons() & Qt::LeftButton ) ) { + if ( !mDragging ) + { + mDragging = true; + } // move map and other canvas items mCanvas->panAction( e ); } @@ -46,16 +51,25 @@ { if ( e->button() == Qt::LeftButton ) { - mDragging = TRUE; } } void QgsMapToolPan::canvasReleaseEvent( QMouseEvent * e ) { - if ( mDragging && e->button() == Qt::LeftButton ) + if ( e->button() == Qt::LeftButton ) { - mCanvas->panActionEnd( e->pos() ); - mDragging = FALSE; + if ( mDragging ) + { + mCanvas->panActionEnd( e->pos() ); + mDragging = FALSE; + } + else // add pan to mouse cursor + { + // transform the mouse pos to map coordinates + QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( e->x(), e->y() ); + mCanvas->setExtent( QgsRectangle( center, center ) ); + mCanvas->refresh(); + } } }