retejs / rete

JavaScript framework for visual programming
https://retejs.org
MIT License
10.17k stars 653 forks source link

Drag multiple Nodes on seperate click is moving the relative node position #442

Closed CorneliaRapp2 closed 1 year ago

CorneliaRapp2 commented 4 years ago

In the plug-in, multiple nodes can only be moved if you hold Ctrl and select several nodes and then immediately drag those nodes without letting the mouseButton go, right? I wanted it to be more like the Unreal editor in terms that I want the selection to stay when you click on a node that is part of the selection instead of just selecting that one node then. Furthermore, I wanted to be able to drag the selected nodes then. I did this (since I cannot alter the plugin really) by buffering the selected nodes and reselecting them when a node is clicked that is in this buffer.

So here is the issue: Whenever I drag the construct now (two selected nodes), the node that I do not directly drag changes it's relative position on the first dragstep (so not continuously, just in the beginning). obviously, I dont want this. I also do not understand why this happens and how to fix it though, because I did not change anything about how the" drag/translate nodes"-thing works, and I don't get it. Thank you in advance for your help!

damiano-sca commented 3 years ago

Hi, I'm currently facing the same issue regarding the translation of the nodes. I'm trying to drag multiple nodes without the need of holding CTRL and the way I was trying to achieve it was by preventing the selection event if the node I'm pressing onto was already selected. (To make this usable I also added a "click outside a node to deselect".)

This is the piece of code that is causing me the node translation issue is this:

ReteComponent.editor.on("nodeselect", (node) => { if (ReteComponent.editor.selected.contains(node)) { return false; } });

It works correctly but it looks like it's not updating the position of the rest of the nodes.

I haven't figured a way around it yet but I'll post here if I come up with something that's working

damiano-sca commented 3 years ago

Got it, when you prevent the (de)selection event, add

editor.trigger('nodeselected', node);

to force the update of the initial nodes position before dragging.

rete-js[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.