right click menu in node view for adding nodes

This commit is contained in:
itsmattkc
2019-04-13 15:57:09 +10:00
parent e20b1d35c2
commit 6bf62017ea
18 changed files with 309 additions and 294 deletions
+8
View File
@@ -4,6 +4,9 @@
#include <QScrollBar>
#include <QDebug>
#include "ui/menu.h"
#include "nodes/node.h"
NodeView::NodeView(QGraphicsScene *scene, QWidget *parent) :
QGraphicsView(scene, parent),
hand_moving_(false)
@@ -20,6 +23,11 @@ void NodeView::mousePressEvent(QMouseEvent *event)
if (event->button() == Qt::MidButton) {
hand_moving_ = true;
drag_start_ = event->pos();
} else if (event->button() == Qt::RightButton && scene()->itemAt(mapToScene(event->pos()), QTransform()) == nullptr) {
// If the user clicked with the right button on empty space, show the context menu
emit RequestContextMenu();
} else {
QGraphicsView::mousePressEvent(event);
}