Skip to content
Permalink
Browse files

Vertex tool, fix escape to stop dragging edge

and make keypress handling cleaner

(cherry picked from commit f3ae6c1)
  • Loading branch information
uclaros authored and nyalldawson committed Jun 19, 2020
1 parent 2484392 commit 73ea3d6b2503e675f9d4c5490567324afa169d67
Showing with 44 additions and 30 deletions.
  1. +44 −30 src/app/vertextool/qgsvertextool.cpp
@@ -1236,38 +1236,52 @@ void QgsVertexTool::updateFeatureBand( const QgsPointLocator::Match &m )

void QgsVertexTool::keyPressEvent( QKeyEvent *e )
{
if ( !mDraggingVertex && !mDraggingEdge && e->key() == Qt::Key_R && e->modifiers() & Qt::ShiftModifier )
switch ( e->key() )
{
startRangeVertexSelection();
return;
}
if ( mSelectionMethod == SelectionRange && e->key() == Qt::Key_Escape )
{
stopRangeVertexSelection();
return;
}

if ( !mDraggingVertex && mSelectedVertices.count() == 0 )
return;

if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace )
{
e->ignore(); // Override default shortcut management
deleteVertex();
}
else if ( e->key() == Qt::Key_Escape )
{
if ( mDraggingVertex )
stopDragging();
}
else if ( e->key() == Qt::Key_Less || e->key() == Qt::Key_Comma )
{
highlightAdjacentVertex( -1 );
}
else if ( e->key() == Qt::Key_Greater || e->key() == Qt::Key_Period )
{
highlightAdjacentVertex( + 1 );
case Qt::Key_Escape:
{
if ( mSelectionMethod == SelectionRange )
stopRangeVertexSelection();
if ( mDraggingVertex || mDraggingEdge )
stopDragging();
break;
}
case Qt::Key_Delete:
case Qt::Key_Backspace:
{
if ( mDraggingVertex || ( !mDraggingEdge && !mSelectedVertices.isEmpty() ) )
{
e->ignore(); // Override default shortcut management
deleteVertex();
}
break;
}
case Qt::Key_R:
{
if ( e->modifiers() & Qt::ShiftModifier && !mDraggingVertex && !mDraggingEdge )
startRangeVertexSelection();
break;
}
case Qt::Key_Less:
case Qt::Key_Comma:
{
if ( !mDraggingVertex && !mDraggingEdge )
highlightAdjacentVertex( -1 );
break;
}
case Qt::Key_Greater:
case Qt::Key_Period:
{
if ( !mDraggingVertex && !mDraggingEdge )
highlightAdjacentVertex( + 1 );
break;
}
default:
{
return;
}
}
return;
}

QgsGeometry QgsVertexTool::cachedGeometry( const QgsVectorLayer *layer, QgsFeatureId fid )

0 comments on commit 73ea3d6

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