0
有什麼辦法處理頂點上的懸停事件?我沒有在mxEvent或任何例子中看到任何相關的,如mouseenter,mouseleave,mouseover等,所以我假設不是。 (是否還有其他狡猾的解決方法?)將懸停事件添加到mxGraph的頂點
有什麼辦法處理頂點上的懸停事件?我沒有在mxEvent或任何例子中看到任何相關的,如mouseenter,mouseleave,mouseover等,所以我假設不是。 (是否還有其他狡猾的解決方法?)將懸停事件添加到mxGraph的頂點
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)
{
if (this.currentState != null)
{
this.dragLeave(me.getEvent(), this.currentState);
}
this.currentState = tmp;
if (this.currentState != null)
{
this.dragEnter(me.getEvent(), this.currentState);
}
}
},
mouseUp: function(sender, me) { },
dragEnter: function(evt, state)
{
if (state != null)
{
this.previousStyle = state.style;
state.style = mxUtils.clone(state.style);
updateStyle(state, true);
state.shape.apply(state);
state.shape.reconfigure();
}
},
dragLeave: function(evt, state)
{
if (state != null)
{
state.style = this.previousStyle;
updateStyle(state, false);
state.shape.apply(state);
state.shape.reconfigure();
}
}
});