简体   繁体   English

如何仅在 JGraphX 中禁用边选择?

[英]How do I disable edge selection only in JGraphX?

I'm trying to disable edge selection only in JGraphX.我试图仅在 JGraphX 中禁用边缘选择。 If I call如果我打电话

mxgraph.setCellsSelectable(false);

This disables selection on all cell, not just edges.这将禁用对所有单元格的选择,而不仅仅是边缘。 Is there something like a setEdgesSelectable ()?有没有像setEdgesSelectable () 这样的东西?

Override:覆盖:

public boolean isCellsSelectable()

in an mxGraph subclass and use that sub-class.在 mxGraph 子类中并使用该子类。 By default that returns mxgraph.cellsSelectable .默认情况下返回mxgraph.cellsSelectable You want something like (not tested at all):你想要这样的东西(根本没有测试):

public boolean isCellsSelectable()
{
    if (model.isEdge())
    {
        return false;
    }

    return cellsSelectable;
}

As of today, the current JGraphX version (3.6) doesn't have the isCellsSelectable() method mentioned in David's answer, but basically the solution stays the same.截至今天,当前的 JGraphX 版本 (3.6) 没有 David 的回答中提到的isCellsSelectable()方法,但基本上解决方案保持不变。

You need just to use the isCellSelectable(Object cell) method as shown below:您只需要使用isCellSelectable(Object cell)方法,如下所示:

public boolean isCellSelectable(Object cell)
{
    if (model.isEdge(cell))
    {
        return false;
    }

    return super.isCellSelectable(cell);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM