added node_selected signal
simple signal to emit list of selected nodes whenever left click is pressed
@@ -20,6 +20,8 @@ from NodeGraphQt.widgets.viewer import NodeViewer
class NodeGraph(QtCore.QObject):
+ node_selected = QtCore.Signal(list)
+
def __init__(self, parent=None):
super(NodeGraph, self).__init__(parent)
self._model = NodeGraphModel()
@@ -32,6 +34,7 @@ class NodeGraph(QtCore.QObject):
self._viewer.moved_nodes.connect(self._on_nodes_moved)
self._viewer.search_triggered.connect(self._on_search_triggered)
self._viewer.connection_changed.connect(self._on_connection_changed)
+ self._viewer.node_selected.connect(self._on_node_selected)
def _init_actions(self):
# setup tab search shortcut.
@@ -61,6 +64,14 @@ class NodeGraph(QtCore.QObject):
self._undo_stack.push(NodeMovedCmd(node, node.pos(), prev_pos))
self._undo_stack.endMacro()
+ def _on_nodes_moved(self, node_data):
+ """
+ called when a node in the viewer is selected on left click.
+
+ """
+ nodes = self.selected_nodes()
+ self.node_selected.emit(nodes)
+
def _on_search_triggered(self, node_type, pos):
"""
called when the tab search widget is triggered in the viewer.
