Skip to content
Snippets Groups Projects
Commit 51ce561c authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Fix right-click menu only opening once

parent 29feb3be
No related branches found
No related tags found
1 merge request!327Fix right-click menu only opening once
Pipeline #96187 passed
...@@ -63,25 +63,22 @@ class DragButton(QPushButton): ...@@ -63,25 +63,22 @@ class DragButton(QPushButton):
self._flipped = False self._flipped = False
self._properties_window = None self._properties_window = None
self.label = None self.label = None
self._context_menu = None
super().__init__(parent) super().__init__(parent)
def contextMenuEvent(self, event): def contextMenuEvent(self, event):
if self._context_menu is None: menu = QMenu()
menu = QMenu() properties = QAction("Properties")
properties = QAction("Properties") menu.addAction(properties)
menu.addAction(properties) properties.triggered.connect(self.show_properties_window)
properties.triggered.connect(self.show_properties_window)
delete = QAction("Delete")
delete = QAction("Delete") menu.addAction(delete)
menu.addAction(delete) delete.triggered.connect(self.remove)
delete.triggered.connect(self.remove)
flip = QAction("Flip horizontal")
flip = QAction("Flip horizontal") menu.addAction(flip)
menu.addAction(flip) flip.triggered.connect(self._flip)
flip.triggered.connect(self._flip) menu.exec_(self.cursor().pos())
self._context_menu = menu
self._context_menu.exec_(self.cursor().pos())
def show_properties_window(self, event=None) -> None: def show_properties_window(self, event=None) -> None:
"""Display the properties window for the associated Operation.""" """Display the properties window for the associated Operation."""
......
...@@ -89,7 +89,6 @@ class OperationItem(QGraphicsItemGroup): ...@@ -89,7 +89,6 @@ class OperationItem(QGraphicsItemGroup):
QCursor(Qt.CursorShape.OpenHandCursor) QCursor(Qt.CursorShape.OpenHandCursor)
) # default cursor when hovering over object ) # default cursor when hovering over object
self._context_menu = None
self._make_component() self._make_component()
# def sceneEvent(self, event: QEvent) -> bool: # def sceneEvent(self, event: QEvent) -> bool:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment