Javascript 在Graphiti中,如何将编辑器放在图形的标签上

Javascript 在Graphiti中,如何将编辑器放在图形的标签上,javascript,Javascript,我试图创建一个可编辑的标签,就像示例connection_labeledit_inplace中的标签一样 我遇到的问题是,我想将标签附加到自定义矢量图形,以代替连接。执行此操作时,标签只是图形的一部分,不要启动编辑器 ivr.shape.menu.MenuItem = graphiti.VectorFigure.extend({ NAME:"ivr.shape.menu.MenuItem", MyOutputPortLocator : graphiti.layout.locator.Loca

我试图创建一个可编辑的标签,就像示例connection_labeledit_inplace中的标签一样

我遇到的问题是,我想将标签附加到自定义矢量图形,以代替连接。执行此操作时,标签只是图形的一部分,不要启动编辑器

ivr.shape.menu.MenuItem = graphiti.VectorFigure.extend({

NAME:"ivr.shape.menu.MenuItem",

MyOutputPortLocator : graphiti.layout.locator.Locator.extend({
    init: function(parent)
    {
        this._super(parent);
    },
    relocate:function(index, figure){
        var w = figure.getParent().getWidth();
        var h = figure.getParent().getHeight();

        figure.setPosition(w, h/2);
    }
}),

/**
 * @constructor
 * Creates a new figure element which are not assigned to any canvas.
 *
 */
init: function( width, height) {
    this._super();
    this.setBackgroundColor( new graphiti.util.Color(200,200,200));
    this.setColor(new graphiti.util.Color(50,50,50));

    // set some good defaults
    //
    if(typeof width === "undefined"){
        this.setDimension(100, 15);
    }
    else{
        this.setDimension(width, height);
    }

    // add port
    var outputLocator = new this.MyOutputPortLocator(this);
    this.createPort("output",outputLocator);

    this.label = new graphiti.shape.basic.Label("I'm a Label");
    this.label.setColor("#0d0d0d");
    this.label.setFontColor("#0d0d0d");
    this.addFigure(this.label, new graphiti.layout.locator.LeftLocator(this));

    this.label.installEditor(new graphiti.ui.LabelInplaceEditor());
},


repaint : function(attributes)
{
    if(this.repaintBlocked===true || this.shape===null){
        return;
    }

    if (typeof attributes === "undefined") {
        attributes = {};
    }

    var box = this.getBoundingBox();
    var center = box.getCenter();
    var path = ["M",box.x,",",box.y];
    path.push("l", box.w-10, ",0");
    path.push("l10,", box.h/2);
    path.push("l-10,", box.h/2);
    path.push("L",box.x,",", box.getBottomLeft().y);
    path.push("Z");
    var strPath = path.join("");
    attributes.path = strPath;

    this._super(attributes);
},


/**
 * @method
 * Called by the framework. Don't call them manually.
 *
 * @private
 **/
createShapeElement:function()
{
    // create dummy line
    return this.canvas.paper.path("M0 0L1 1");
}
}))

在本例中,我将标签放在图形的左侧,但显然,我将制作一个定位器,将标签放在图形上(以防它更改某些内容)


在我看来,问题来自“graphiti.Canvas.getBestFigure()”的工作方式。函数只检查直接连接到“graphity.Canvas”的元素。此外,函数缺少一些递归,无法在子级上传播事件。

Graphiti提供了一个中心定位器。 该图可以捕捉到所有事件,如dblClick


…您使用的是最新版本吗?

当然,我使用的是最新版本,我知道我可以捕捉到一个人物的点击。问题是事件不会传播到画布上人物的子人物。1.0.0版已经过时,文档告诉它现在应该可以工作了。伟大的