开发者

mxGraph editor - fire an event when a node is created

I'm playing with the sample mxGraph editor that comes with JGraph. I have a method which I'd like to be called every time a new node is created. Do 开发者_开发百科you know how to do this?

I have a feeling it has something to do with mxGraphComponent, but I couldn't figure out how to do it.


Have a look at the API docs of the mxGraph class. It fires a number of granular events to specify what changes have occurred. You are most likely interested in mxEvent.CELLS_ADDED. So add a listener with:

graph.addListener(mxEvent.CELLS_ADDED, myHandler);

where myHandler implements the mxIEventListener interface that requires the invoke method to be implemented (your method that gets called when the event is fired).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜