Description
The CutSelection
method in the GraphView
class is used to cut the currently selected nodes or elements within the graph editor. This operation removes the selected items from the graph and places them into a clipboard, allowing them to be pasted elsewhere if needed. This is a common operation in graphical editors, enabling users to reorganize or refactor their node graphs efficiently.
Usage
To use the CutSelection
method, ensure that you have a valid instance of GraphView
and that there are nodes or elements currently selected in the graph. Invoke the method to cut the selected items:
var graphView = new GraphView();
// Assume some nodes are selected in the graphView
graphView.CutSelection();
After calling this method, the selected nodes will be removed from the graph and can be pasted elsewhere using the PasteSelection
method.
Example
// Example of using CutSelection in a GraphView
GraphView graphView = new GraphView();
// Select some nodes in the graphView
// ... (selection logic here)
// Cut the selected nodes
graphView.CutSelection();
// The selected nodes are now removed and can be pasted elsewhere.