1
votes

I'm implementing functionality to create a link between two nodes on Shift+Alt+Click. Like this

function graphSelectionChange(event){
var selection = event.selection;
if (selection.length === 2 && event.altKey){
    var fromitem=selection[0];
    var toitem=selection[1];
    chart.addData({
        links:[{
            "id":"ll"+nextId,
            from:fromitem.id, 
            to:toitem.id,
            "style":{"label":"newLink"}
            }]
        });
    nextId += 1;
    }
} 

The altKey seems not to be detected. According to this http://jsfiddle.net/Rw4km/ it is the alt/option button on a keyboard. Any clue?

1

1 Answers

0
votes

Use click event (it also has selection attribute).

Selection event does not have altKey property.

There are other selection changes, like selected nodes disappearing, that do not have associated mouse clicks an you probably do not want a link added in such case.