jointjs:通过单击链接阻止添加顶点 [英] jointjs: prevent adding vertex by clicking on link

查看:115
本文介绍了jointjs:通过单击链接阻止添加顶点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过双击链接为链接添加标签。所以这是我的尝试:

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?

推荐答案

如文档中所示( http://jointjs.com /api#joint.dia.LinkView:addVertex )只需将此部分添加到 joint.dia.Paper

As shown in the docs (http://jointjs.com/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;
    }

这篇关于jointjs:通过单击链接阻止添加顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆