我想删除 draw2d.js 中两个对象之间的连接。我试图找到删除连接的直接方法,但我没有找到它。所以请告诉我是否有任何方法或是否有任何方法可以删除或断开连接。提前致谢!
问问题
1156 次
2 回答
1
没有CommandStack
支持:
canvas.remove(connection);
支持CommandStack
(撤消/重做):
var cmd = new draw2d.command.CommandDelete(connection);
canvas.getCommandStack().execute(cmd);
于 2012-07-16T13:03:16.060 回答
0
draw2d.ContextmenuConnection.prototype.getContextMenu = function() {
var menu = new draw2d.Menu();
menu.appendMenuItem(new draw2d.MenuItem("Disconnect", null, function() {
//draw2d.Connection.workflow.removeFigure(draw2d.Connection.prototype);
var cmd = new draw2d.CommandDelete(**draw2d.Connection**);
draw2d.Connection.prototype.workflow.getCommandStack().excute(cmd);
}));
};
您必须将对象移交给 CommandDelete 的构造函数,而不是draw2d.Connection
见下文:
draw2d.ContextmenuConnection.prototype.getContextMenu = function() {
var menu = new draw2d.Menu();
var oThis = this;
menu.appendMenuItem(new draw2d.MenuItem("Disconnect", null, function() {
//draw2d.Connection.workflow.removeFigure(draw2d.Connection.prototype);
var cmd = new draw2d.CommandDelete(oThis);
draw2d.Connection.prototype.workflow.getCommandStack().excute(cmd);
}));
};
于 2012-07-17T05:45:05.713 回答