@dustinormond wrote:
I am wondering how to copy, cut, and paste items in nodes rather than the nodes or links themselves. Essentially, I am looking to replace
console.log("copy");
andconsole.log("cut");
in the code below. Then I would need to figure out how to paste them and am not sure where to begin here:// finds all selected attributes or fields function findAllSelectedFields() { var fields = []; for (var nit = fileDiagram.nodes; nit.next(); ) { var node = nit.value; var table = node.findObject("FIELDS"); if (table) { for (var iit = table.elements; iit.next(); ) { var fieldPanel = iit.value; if (fieldPanel.background !== "transparent") fields.push(fieldPanel); } } } return fields; } // function to copy selected fields function copyFields(fields) { console.log("copy"); } // function to cut selected fields function cutFields(fields) { console.log("cut"); } // handles copying fileDiagram.commandHandler.copySelection = function() { var fields = findAllSelectedFields(); if (fields.length > 0) { copyFields(fields); } else { x = 0; y = 0; go.CommandHandler.prototype.copySelection.call(fileDiagram.commandHandler); } }; // handles cutting fileDiagram.commandHandler.cutSelection = function() { var fields = findAllSelectedFields(); if (fields.length > 0) { cutFields(fields); } else { x = 0; y = 0; go.CommandHandler.prototype.cutSelection.call(fileDiagram.commandHandler); } };
Posts: 1
Participants: 1