Skip to content

Commit

Permalink
Use the middle mouse button for panning
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@10314 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Mar 20, 2009
1 parent 4af6e9d commit c9aab40
Showing 1 changed file with 42 additions and 19 deletions.
61 changes: 42 additions & 19 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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 );
}
}


Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit c9aab40

Please sign in to comment.