Skip to content

Commit c9aab40

Browse files
author
mhugent
committedMar 20, 2009
Use the middle mouse button for panning
git-svn-id: http://svn.osgeo.org/qgis/trunk@10314 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 4af6e9d commit c9aab40

File tree

1 file changed

+42
-19
lines changed

1 file changed

+42
-19
lines changed
 

‎src/gui/qgsmapcanvas.cpp

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -767,12 +767,24 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
767767
return;
768768
}
769769

770-
// call handler of current map tool
771-
if ( mMapTool )
772-
mMapTool->canvasPressEvent( e );
770+
//use middle mouse button for panning, map tools won't receive any events in that case
771+
if(e->button() == Qt::MidButton)
772+
{
773+
mCanvasProperties->panSelectorDown = true;
774+
mCanvasProperties->rubberStartPoint = mCanvasProperties->mouseLastXY;
775+
}
776+
else
777+
{
778+
779+
// call handler of current map tool
780+
if ( mMapTool )
781+
mMapTool->canvasPressEvent( e );
782+
}
773783

774784
if ( mCanvasProperties->panSelectorDown )
785+
{
775786
return;
787+
}
776788

777789
mCanvasProperties->mouseButtonDown = true;
778790
mCanvasProperties->rubberStartPoint = e->pos();
@@ -787,25 +799,34 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )
787799
return;
788800
}
789801

790-
// call handler of current map tool
791-
if ( mMapTool )
802+
//use middle mouse button for panning, map tools won't receive any events in that case
803+
if(e->button() == Qt::MidButton)
804+
{
805+
mCanvasProperties->panSelectorDown = false;
806+
panActionEnd( mCanvasProperties->mouseLastXY );
807+
}
808+
else
792809
{
793-
// right button was pressed in zoom tool? return to previous non zoom tool
794-
if ( e->button() == Qt::RightButton && mMapTool->isTransient() )
810+
// call handler of current map tool
811+
if ( mMapTool )
795812
{
796-
QgsDebugMsg( "Right click in map tool zoom or pan, last tool is " +
813+
// right button was pressed in zoom tool? return to previous non zoom tool
814+
if ( e->button() == Qt::RightButton && mMapTool->isTransient() )
815+
{
816+
QgsDebugMsg( "Right click in map tool zoom or pan, last tool is " +
797817
QString( mLastNonZoomMapTool ? "not null." : "null." ) );
798818

799-
// change to older non-zoom tool
800-
if ( mLastNonZoomMapTool )
801-
{
802-
QgsMapTool* t = mLastNonZoomMapTool;
803-
mLastNonZoomMapTool = NULL;
804-
setMapTool( t );
819+
// change to older non-zoom tool
820+
if ( mLastNonZoomMapTool )
821+
{
822+
QgsMapTool* t = mLastNonZoomMapTool;
823+
mLastNonZoomMapTool = NULL;
824+
setMapTool( t );
825+
}
826+
return;
805827
}
806-
return;
807-
}
808828
mMapTool->canvasReleaseEvent( e );
829+
}
809830
}
810831

811832

@@ -975,10 +996,12 @@ void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e )
975996
{
976997
panAction( e );
977998
}
978-
979-
// call handler of current map tool
980-
if ( mMapTool )
999+
else
1000+
{
1001+
// call handler of current map tool
1002+
if ( mMapTool )
9811003
mMapTool->canvasMoveEvent( e );
1004+
}
9821005

9831006
// show x y on status bar
9841007
QPoint xy = e->pos();

0 commit comments

Comments
 (0)
Please sign in to comment.