yfiles for html2.5,我目前使用graphEditorInputMode.moveUnselectedInputMode在不选择node的情况下用鼠标直接拖拽移动node,但在用Marquee选择多个nodes后,我想用鼠标拖一个节点从而同时来移动多个节点时该如何实现?
时间: 2023-12-14 13:38:31 浏览: 19
您可以使用GraphEditorInputMode.moveInputMode来实现所需的特定功能。此模式支持在选择节点的同时移动它们,从而可以轻松地实现您所需的目标。您可以使用以下代码段实现此功能:
```javascript
var graphEditorInputMode = new yfiles.input.GraphEditorInputMode();
graphEditorInputMode.moveInputMode.priority = yfiles.input.DoubleTapRecognizer.PRIO + 1;
graphEditorInputMode.moveInputMode.clickableElements = yfiles.input.GraphItemTypes.NODE;
graphEditorInputMode.moveInputMode.moveCursor = yfiles.system.Cursors.GRAB;
// Enable the selecting of nodes with Shift+Click.
graphEditorInputMode.moveInputMode.selectableItems = yfiles.input.GraphItemTypes.NODE;
graphEditorInputMode.moveInputMode.allowResizeNodes = false;
graphEditorInputMode.moveInputMode.addMovedItemsToGroup = true;
graphEditorInputMode.moveInputMode.snapContext = new yfiles.input.SnapContext();
graphEditorInputMode.moveUnselectedInputMode.priority = yfiles.input.DoubleTapRecognizer.PRIO + 2;
graphEditorInputMode.moveUnselectedInputMode.clickableElements = yfiles.input.GraphItemTypes.NONE;
graphEditorInputMode.moveUnselectedInputMode.moveCursor = yfiles.system.Cursors.MOVE;
graphEditorInputMode.moveUnselectedInputMode.allowDragSelectedItemsOnly = true;
graphEditorInputMode.marqueeSelectionInputMode.priority = yfiles.input.DoubleTapRecognizer.PRIO + 3;
graphEditorInputMode.marqueeSelectionInputMode.showInvisibleItems = false;
graphEditorInputMode.marqueeSelectionInputMode.itemTypes = yfiles.input.GraphItemTypes.NODE;
graphEditorInputMode.marqueeSelectionInputMode.enabled = true;
var graphControl = new yfiles.view.GraphControl("graphControl");
graphControl.inputMode = graphEditorInputMode;
```
此代码段设置了不同的输入模式,以实现您所需的目标。您需要在GraphEditorInputMode中设置moveInputMode和moveUnselectedInputMode选项,以便选择和移动节点。然后,您可以在marqueeSelectionInputMode中设置选择节点的选项。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)