Skip to content
Permalink
Browse files

Allow cancelation of polygon/polyline creation

  • Loading branch information
nyalldawson committed Oct 17, 2017
1 parent 4e8483e commit 87ef5c52b00634ba9e1a84868e3ed2136fcc9a07
@@ -45,6 +45,8 @@ class QgsLayoutViewToolAddNodeItem : QgsLayoutViewTool

virtual void layoutReleaseEvent( QgsLayoutViewMouseEvent *event );

virtual void keyPressEvent( QKeyEvent *event );

virtual void deactivate();


@@ -111,6 +111,38 @@ void QgsLayoutViewToolAddNodeItem::layoutReleaseEvent( QgsLayoutViewMouseEvent *
}
}

void QgsLayoutViewToolAddNodeItem::keyPressEvent( QKeyEvent *event )
{
if ( !mRubberBand || event->isAutoRepeat() )
{
event->ignore();
return;
}

if ( event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace )
{
if ( mPolygon.size() > 2 )
{
//remove last added vertex
mPolygon.pop_back();
setRubberBandNodes();
}
else
{
// all deleted, cancel
mRubberBand.reset();
}
}
else if ( event->key() == Qt::Key_Escape )
{
mRubberBand.reset();
}
else
{
event->ignore();
}
}

void QgsLayoutViewToolAddNodeItem::deactivate()
{
if ( mRubberBand )
@@ -55,6 +55,7 @@ class GUI_EXPORT QgsLayoutViewToolAddNodeItem : public QgsLayoutViewTool
void layoutPressEvent( QgsLayoutViewMouseEvent *event ) override;
void layoutMoveEvent( QgsLayoutViewMouseEvent *event ) override;
void layoutReleaseEvent( QgsLayoutViewMouseEvent *event ) override;
void keyPressEvent( QKeyEvent *event ) override;
void deactivate() override;

signals:

0 comments on commit 87ef5c5

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