hoverstyle示例演示如何实现此操作。这个问题的相关代码:
// Changes fill color to red on mouseover
graph.addMouseListener(
{
currentState: null,
previousStyle: null,
mouseDown: function(sender, me)
{
if (this.currentState != null)
{
this.dragLeave(me.getEvent(), this.currentState);
this.currentState = null;
}
},
mouseMove: function(sender, me)
{
if (this.currentState != null && me.getState() == this.currentState)
{
return;
}
var tmp = graph.view.getState(me.getCell());
// Ignores everything but vertices
if (graph.isMouseDown || (tmp != null && !
graph.getModel().isVertex(tmp.cell)))
{
tmp = null;
}
if (tmp != this.currentState)