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).
精彩评论