“ externalObjectDrop”函数中的“主题”参数为空

时间:2019-08-13 06:29:08

标签: gojs

“ externalObjectDrop”函数中的

e.subject参数带有count = 0, 尽管拖动的零件已移动到模型中。

在图中:

  allowCopy: true,
  allowUndo: false,
  allowInsert: true,
  allowDragOut: true,
  allowDrop: true,
  allowMove: true,
  "ExternalObjectsDropped": (e) => {
                this.externalObjectDrop(e);
            }

功能:

  externalObjectDrop(e) {
 e.diagram.commandHandler.deleteSelection();
 e.parameter.commandHandler.deleteSelection();
   //e.subject.count is 0.
}

1 个答案:

答案 0 :(得分:0)

e.subject包含引用而不是值。因此,致电后:e.parameter.commandHandler.deleteSelection()  -e.subject变为空。 所以我将e.subject保存为参数,然后删除选择:

const nodes = e.subject.toArray();
 e.parameter.commandHandler.deleteSelection();