Skip to content
Permalink
Browse files
[FEATURE] Support single click to select with freehand select tool
This brings the behaviour of the freehand select into line with
the select by rectangle tool, which allows clicks without drag to
select a single feature.

(fix #14747)
  • Loading branch information
nyalldawson committed May 2, 2016
1 parent 70adf26 commit d3fcdb4
Showing 1 changed file with 18 additions and 1 deletion.
@@ -68,12 +68,29 @@ void QgsMapToolSelectFreehand::canvasReleaseEvent( QgsMapMouseEvent* e )
if ( !mRubberBand )
return;

bool singleSelect = false;
if ( mRubberBand->numberOfVertices() > 0 && mRubberBand->numberOfVertices() <= 2 )
{
// single click, not drag - create a rectangle around clicked point
QgsVectorLayer* vlayer = QgsMapToolSelectUtils::getCurrentVectorLayer( mCanvas );
if ( vlayer )
{
QRect selectRect;
QgsMapToolSelectUtils::expandSelectRectangle( selectRect, vlayer, e->pos() );
QgsMapToolSelectUtils::setRubberBand( mCanvas, selectRect, mRubberBand );
singleSelect = true;
}
}

if ( mRubberBand->numberOfVertices() > 2 )
{
QgsGeometry* shapeGeom = mRubberBand->asGeometry();
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, shapeGeom, e );
QgsMapToolSelectUtils::setSelectFeatures( mCanvas, shapeGeom,
e->modifiers() & Qt::ShiftModifier,
e->modifiers() & Qt::ControlModifier, singleSelect );
delete shapeGeom;
}

mRubberBand->reset( QGis::Polygon );
delete mRubberBand;
mRubberBand = nullptr;

0 comments on commit d3fcdb4

Please sign in to comment.