Skip to content
Permalink
Browse files

Use the middle mouse button for panning

git-svn-id: http://svn.osgeo.org/qgis/trunk@10314 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Mar 20, 2009
1 parent 4af6e9d commit c9aab40207e7a185ecd3a528535873b34b1061c1
Showing with 42 additions and 19 deletions.
  1. +42 −19 src/gui/qgsmapcanvas.cpp
@@ -767,12 +767,24 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
return;
}

// call handler of current map tool
if ( mMapTool )
mMapTool->canvasPressEvent( e );
//use middle mouse button for panning, map tools won't receive any events in that case
if(e->button() == Qt::MidButton)
{
mCanvasProperties->panSelectorDown = true;
mCanvasProperties->rubberStartPoint = mCanvasProperties->mouseLastXY;
}
else
{

// call handler of current map tool
if ( mMapTool )
mMapTool->canvasPressEvent( e );
}

if ( mCanvasProperties->panSelectorDown )
{
return;
}

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

// call handler of current map tool
if ( mMapTool )
//use middle mouse button for panning, map tools won't receive any events in that case
if(e->button() == Qt::MidButton)
{
mCanvasProperties->panSelectorDown = false;
panActionEnd( mCanvasProperties->mouseLastXY );
}
else
{
// right button was pressed in zoom tool? return to previous non zoom tool
if ( e->button() == Qt::RightButton && mMapTool->isTransient() )
// call handler of current map tool
if ( mMapTool )
{
QgsDebugMsg( "Right click in map tool zoom or pan, last tool is " +
// right button was pressed in zoom tool? return to previous non zoom tool
if ( e->button() == Qt::RightButton && mMapTool->isTransient() )
{
QgsDebugMsg( "Right click in map tool zoom or pan, last tool is " +
QString( mLastNonZoomMapTool ? "not null." : "null." ) );

// change to older non-zoom tool
if ( mLastNonZoomMapTool )
{
QgsMapTool* t = mLastNonZoomMapTool;
mLastNonZoomMapTool = NULL;
setMapTool( t );
// change to older non-zoom tool
if ( mLastNonZoomMapTool )
{
QgsMapTool* t = mLastNonZoomMapTool;
mLastNonZoomMapTool = NULL;
setMapTool( t );
}
return;
}
return;
}
mMapTool->canvasReleaseEvent( e );
}
}


@@ -975,10 +996,12 @@ void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e )
{
panAction( e );
}

// call handler of current map tool
if ( mMapTool )
else
{
// call handler of current map tool
if ( mMapTool )
mMapTool->canvasMoveEvent( e );
}

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

0 comments on commit c9aab40

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