admin管理员组文章数量:1327843
I am new working with mxgraph in javascript and have some specific questions on how to use events from the graph. There are two basic scenarios that I am interested to work with and understand better:
1) I am interested to add vertices using the drag-and-drop mechanisms in the examples (i.e. using mxgraph toolbar). For this, I want receive an event BEFORE the node is added to the graph to be able to do two things before the "cells added" event is fired:
a) Use logic incorporate data for the vertex (i.e. timestamp)
b) Be able to assign a custom id to each vertex
Could you please be able to help me understand how to handle this case? I have been looking at the online docs and cannot see a very straightforward description of how events actually work from "A to B".
Thanks a lot
I am new working with mxgraph in javascript and have some specific questions on how to use events from the graph. There are two basic scenarios that I am interested to work with and understand better:
1) I am interested to add vertices using the drag-and-drop mechanisms in the examples (i.e. using mxgraph toolbar). For this, I want receive an event BEFORE the node is added to the graph to be able to do two things before the "cells added" event is fired:
a) Use logic incorporate data for the vertex (i.e. timestamp)
b) Be able to assign a custom id to each vertex
Could you please be able to help me understand how to handle this case? I have been looking at the online docs and cannot see a very straightforward description of how events actually work from "A to B".
Thanks a lot
Share asked Jan 16, 2017 at 10:24 crobbocrobbo 2904 silver badges10 bronze badges1 Answer
Reset to default 6Hi its difficult to understand you question can you please provide some code snap. Anyway i provide two example of mxGraph evet
1.Click Event
//Cell click event
graph.addListener(mxEvent.CLICK, function (sender, evt) {
var cell = evt.getProperty("cell"); // cell may be null
if (cell != null) {
SelectGraphCell(cell);
graph.setSelectionCell(cell);
}
evt.consume();
});
- Mouse wheel Event
mxEvent.addMouseWheelListener(function (evt, up) {
Print = false;
if (evt.ctrlKey && up) {
graph.zoomIn();
mxEvent.consume(evt);
} else if (evt.ctrlKey) {
graph.zoomOut();
mxEvent.consume(evt);
}
});
ZoomIn,ZoomOut,selectgraphcell and set selectioncell are already defined function that are use these event according their purpose
本文标签: javascriptHow to work with mxgraph eventsStack Overflow
版权声明:本文标题:javascript - How to work with mxgraph events - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742220739a2435407.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论