nodeview: allow esc key to cancel adding a node

This commit is contained in:
itsmattkc
2020-02-16 11:44:35 +11:00
parent fa0f732d39
commit a6f4922d66
2 changed files with 15 additions and 0 deletions
+13
View File
@@ -215,6 +215,19 @@ void NodeView::ItemsChanged()
}
}
void NodeView::keyPressEvent(QKeyEvent *event)
{
QGraphicsView::keyPressEvent(event);
if (event->key() == Qt::Key_Escape && attached_item_) {
DetachItemFromCursor();
// We undo the last action which SHOULD be adding the node
// FIXME: Possible danger of this not being the case?
Core::instance()->undo_stack()->undo();
}
}
void NodeView::mousePressEvent(QMouseEvent *event)
{
if (attached_item_) {