Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 6971

How to override the keyboard copy function?

$
0
0

@kid_freak wrote:

I want to use keyboard to copy and past . The default Ctrl+c and Ctrl+v Copy function is copy all attributes.But I just want to copy some attributes what I need . For example , there are a NodeDataArray:

[ { "size":"", "pos":"705 -35", "text2":"0", "id":476, "category":"shelf", "key":330, "stockNo":""} ]

When I copy the node use ctrl+c and ctrl+v , the new NodeDataArray is :

[ { "size":"", "pos":"705 -35", "text2":"0", "id":476, "category":"shelf", "key":330, "stockNo":""},
{ "size":"", "pos":"705 -35", "text2":"0", "id":476, "category":"shelf", "key":330, "stockNo":""} ]

You can see the json are same . But Iin this way , I can't update those node into dataBase because the two node's Id is same!I need to override the keyboard copy event and don't copy the "id" attribute.

By the way,I had override the deleteEnent:

        // notice whenever the selection may have changed
        myDiagram.addDiagramListener("ChangedSelection", function(e) {
            enableAll();
        });
        // notice when the Paste command may need to be reenabled
        myDiagram.addDiagramListener("ClipboardChanged", function(e) {
            enableAll();
        });
        // notice whenever a transaction or undo/redo has occurred
        myDiagram.addModelChangedListener(function(e) {
            if (e.isTransactionFinished) enableAll();
        });
function enableAll() {
        var cmdhnd = myDiagram.commandHandler;
        var delFlag = false;
        cmdhnd.canDeleteSelection = function () {
            //to do my delete ajax and something
           //return boolean
        };
    }

I know the return value of canDeleteSelection is boolean .But what is the "copySelection()" and the "copyToClipboard(coll)"function's return value? And how to override it?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6971

Trending Articles