|
1 | 1 | from PySide2 import QtCore, QtGui, QtWidgets, QtOpenGL |
2 | 2 |
|
3 | 3 | from node_editor.gui.connection import Connection |
| 4 | +from node_editor.gui.node import Node |
4 | 5 |
|
5 | 6 |
|
6 | 7 | class View(QtWidgets.QGraphicsView): |
@@ -125,17 +126,25 @@ def drawBackground(self, painter, rect): |
125 | 126 |
|
126 | 127 | def contextMenuEvent(self, event): |
127 | 128 | cursor = QtGui.QCursor() |
128 | | - origin = self.mapFromGlobal(cursor.pos()) |
129 | | - pos = self.mapToScene(origin) |
| 129 | + # origin = self.mapFromGlobal(cursor.pos()) |
| 130 | + pos = self.mapFromGlobal(cursor.pos()) |
130 | 131 | item = self.itemAt(event.pos()) |
131 | 132 |
|
132 | 133 | if item: |
133 | | - if isinstance(item, Connection): |
| 134 | + if isinstance(item, Node): |
134 | 135 |
|
135 | | - print("Found Connection", item) |
136 | | - elbow_action = QtWidgets.QAction("Add Elbow", self) |
137 | | - elbow_action.triggered.connect(self.add_elbow) |
138 | | - self.menu.addAction(elbow_action) |
| 136 | + print("Found Node", item) |
| 137 | + |
| 138 | + menu = QtWidgets.QMenu(self) |
| 139 | + |
| 140 | + hello_action = QtWidgets.QAction("Hello", self) |
| 141 | + |
| 142 | + # elbow_action.triggered.connect(self.add_elbow) |
| 143 | + menu.addAction(hello_action) |
| 144 | + action = menu.exec_(self.mapToGlobal(pos)) |
| 145 | + |
| 146 | + if action == hello_action: |
| 147 | + print("Hello") |
139 | 148 |
|
140 | 149 | def dragEnterEvent(self, e): |
141 | 150 |
|
|
0 commit comments