3

I'm trying to disable edge selection only in JGraphX. If I call

mxgraph.setCellsSelectable(false);

This disables selection on all cell, not just edges. Is there something like a setEdgesSelectable()?

TylerH
  • 20,799
  • 66
  • 75
  • 101
user3062529
  • 87
  • 1
  • 8

2 Answers2

4

Override:

public boolean isCellsSelectable()

in an mxGraph subclass and use that sub-class. By default that returns mxgraph.cellsSelectable. You want something like (not tested at all):

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

    return cellsSelectable;
}
Frodo Baggins
  • 8,290
  • 6
  • 45
  • 55
1

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.

You need just to use the isCellSelectable(Object cell) method as shown below:

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

    return super.isCellSelectable(cell);
}
Insac
  • 800
  • 5
  • 18