@@ -83,10 +83,13 @@ def __init__(self, parent=None):
8383
8484 self ._ctx_menu = BaseMenu ('NodeGraph' , self )
8585 self ._ctx_node_menu = BaseMenu ('Nodes' , self )
86+ self ._ctx_port_menu = BaseMenu ('Ports' , self )
8687 menu_bar .addMenu (self ._ctx_menu )
8788 menu_bar .addMenu (self ._ctx_node_menu )
89+ menu_bar .addMenu (self ._ctx_port_menu )
8890
8991 self ._ctx_node_menu .setDisabled (True )
92+ self ._ctx_port_menu .setDisabled (True )
9093
9194 self .acyclic = True
9295 self .LMB_state = False
@@ -157,7 +160,7 @@ def resizeEvent(self, event):
157160
158161 def contextMenuEvent (self , event ):
159162 self .RMB_state = False
160- ctx_menu = self . _ctx_menu
163+ ctx_menu = None
161164
162165 if self ._ctx_node_menu .isEnabled ():
163166 pos = self .mapToScene (self ._previous_pos )
@@ -166,10 +169,13 @@ def contextMenuEvent(self, event):
166169 if nodes :
167170 node = nodes [0 ]
168171 ctx_menu = self ._ctx_node_menu .get_menu (node .type_ )
169- for action in ctx_menu .actions ():
170- if not action .menu ():
171- action .node_id = node .id
172- if ctx_menu and ctx_menu .isEnabled ():
172+ if ctx_menu :
173+ for action in ctx_menu .actions ():
174+ if not action .menu ():
175+ action .node_id = node .id
176+
177+ ctx_menu = ctx_menu or self ._ctx_menu
178+ if ctx_menu .isEnabled ():
173179 ctx_menu .exec_ (event .globalPos ())
174180 else :
175181 return super (NodeViewer , self ).contextMenuEvent (event )
0 commit comments