【发布时间】:2021-08-06 19:05:33
【问题描述】:
当我们拖动一个顶点时,我想将虚线的颜色从黑色变为红色
问题:我想在拖动时将虚线颜色从黑色变为红色
这是它在拖动时的显示方式
我试图在 mxConstants 中找到拖动时的虚线颜色,但没有找到
function main(container)
{
// Checks if the browser is supported
if (!mxClient.isBrowserSupported())
{
// Displays an error message if the browser is not supported.
mxUtils.error('Browser is not supported!', 200, false);
}
else
{
// Disables the built-in context menu
mxEvent.disableContextMenu(container);
// Creates the graph inside the given container
var graph = new mxGraph(container);
// Enables rubberband selection
new mxRubberband(graph);
// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
var parent = graph.getDefaultParent();
// Adds cells to the model in a single step
graph.getModel().beginUpdate();
try
{
var v1 = graph.insertVertex(parent, null, 'Hello,', 20, 20, 80, 30);
}
finally
{
// Updates the display
graph.getModel().endUpdate();
}
}
};
<html>
<head>
<title>Toolbar example for mxGraph</title>
<script type="text/javascript">
mxBasePath = 'https://jgraph.github.io/mxgraph/javascript/src';
</script>
<script src="https://jgraph.github.io/mxgraph/javascript/src/js/mxClient.js"></script>
<script src="./app.js"></script>
</head>
<body onload="main(document.getElementById('graphContainer'))">
<div id="graphContainer">
</div>
</body>
</html>
请帮助我提前谢谢!!!
【问题讨论】:
-
您正在使用
insertVertex,并且很难更改拖动对象的预览。如果你使用mxUtils.makeDraggable,我有你想要的解决方案 -
在我使用
mxUtils.makeDraggable的实际项目中,请发布您的解决方案,我会接受您的回答。但请记住,解决方案必须在画布上工作 -
在画布外我也有解决方案。在画布上,无论我使用
insertVertex还是其他任何东西都没有任何区别
标签: javascript jquery mxgraph