Skip to content
Snippets Groups Projects
addnodetool.js 473 B
Newer Older
  • Learn to ignore specific revisions
  • class AddNodeTool extends Tool {
        constructor(key) {
            super("Add node", "addnode", key);
        }
    
        onBackgroundClick(event, positions) {
            var node = {};
    
            // Set position
            node.fx = positions.graph.x;
            node.fy = positions.graph.y;
    
            var node = graph.addNode(node);
    
            if (node === undefined) {
                console.error("Couldn't add new node");
                return;
            }
    
            state.setSelectedItem(node);
        }
    }