admin管理员组

文章数量:1277896

I would like to add a label to a link by doing a doubleclick on the link. So this is my attempt:

paper.on({
    'cell:pointerdblclick': function(cellView, event, x, y){
        if (cellView.model.isLink()) {
            cellView.model.label(0, {
                position: .5,
                attrs: {
                    rect: { fill: 'white' },
                    text: { text: 'my label' }
                }
            });
        }
    },
});

The problem is, that by doing a doubleclick there is also a vertex beeing created at the same time. How can I prevent that?

Or what would be another simple way to let users add a label for a link?

I would like to add a label to a link by doing a doubleclick on the link. So this is my attempt:

paper.on({
    'cell:pointerdblclick': function(cellView, event, x, y){
        if (cellView.model.isLink()) {
            cellView.model.label(0, {
                position: .5,
                attrs: {
                    rect: { fill: 'white' },
                    text: { text: 'my label' }
                }
            });
        }
    },
});

The problem is, that by doing a doubleclick there is also a vertex beeing created at the same time. How can I prevent that?

Or what would be another simple way to let users add a label for a link?

Share Improve this question asked Oct 24, 2015 at 19:51 user3142695user3142695 17.4k55 gold badges194 silver badges375 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 15

As shown in the docs (http://jointjs./api#joint.dia.LinkView:addVertex) just add this part to joint.dia.Paper:

    interactive: function(cellView) {
        if (cellView.model instanceof joint.dia.Link) {
            // Disable the default vertex add functionality on pointerdown.
            return { vertexAdd: false };
        }
        return true;
    }

本文标签: javascriptjointjs prevent adding vertex by clicking on linkStack Overflow