Skip to content

Commit 29318c7

Browse files
committed
added invert_selection func.
1 parent c292559 commit 29318c7

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

NodeGraphQt/base/graph.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,18 @@ def clear_selection(self):
15501550
[node.set_selected(False) for node in self.all_nodes()]
15511551
self._undo_stack.endMacro()
15521552

1553+
def invert_selection(self):
1554+
"""
1555+
Inverts the current node selection.
1556+
"""
1557+
if not self.selected_nodes():
1558+
self.select_all()
1559+
return
1560+
self._undo_stack.beginMacro('invert selection')
1561+
for node in self.all_nodes():
1562+
node.set_selected(not node.selected())
1563+
self._undo_stack.endMacro()
1564+
15531565
def get_node_by_id(self, node_id=None):
15541566
"""
15551567
Returns the node from the node id string.

examples/hotkeys/hotkey_functions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ def clear_node_selection(graph):
164164
graph.clear_selection()
165165

166166

167+
def invert_node_selection(graph):
168+
"""
169+
Invert node selection.
170+
"""
171+
graph.invert_selection()
172+
173+
167174
def disable_nodes(graph):
168175
"""
169176
Toggle disable on selected nodes.

examples/hotkeys/hotkeys.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@
9898
"file":"../examples/hotkeys/hotkey_functions.py",
9999
"function_name":"clear_node_selection",
100100
"shortcut":"Ctrl+Shift+A"
101+
},
102+
{
103+
"type":"command",
104+
"label":"Invert Selection",
105+
"file":"../examples/hotkeys/hotkey_functions.py",
106+
"function_name":"invert_node_selection"
101107
},
102108
{
103109
"type":"command",

0 commit comments

Comments
 (0)