@@ -767,12 +767,24 @@ void QgsMapCanvas::mousePressEvent( QMouseEvent * e )
767
767
return ;
768
768
}
769
769
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
+ }
773
783
774
784
if ( mCanvasProperties ->panSelectorDown )
785
+ {
775
786
return ;
787
+ }
776
788
777
789
mCanvasProperties ->mouseButtonDown = true ;
778
790
mCanvasProperties ->rubberStartPoint = e->pos ();
@@ -787,25 +799,34 @@ void QgsMapCanvas::mouseReleaseEvent( QMouseEvent * e )
787
799
return ;
788
800
}
789
801
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
792
809
{
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 )
795
812
{
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 " +
797
817
QString ( mLastNonZoomMapTool ? " not null." : " null." ) );
798
818
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 ;
805
827
}
806
- return ;
807
- }
808
828
mMapTool ->canvasReleaseEvent ( e );
829
+ }
809
830
}
810
831
811
832
@@ -975,10 +996,12 @@ void QgsMapCanvas::mouseMoveEvent( QMouseEvent * e )
975
996
{
976
997
panAction ( e );
977
998
}
978
-
979
- // call handler of current map tool
980
- if ( mMapTool )
999
+ else
1000
+ {
1001
+ // call handler of current map tool
1002
+ if ( mMapTool )
981
1003
mMapTool ->canvasMoveEvent ( e );
1004
+ }
982
1005
983
1006
// show x y on status bar
984
1007
QPoint xy = e->pos ();
0 commit comments