miroiu / nodify

Highly performant and modular controls for node-based editors designed for data-binding and MVVM.
https://miroiu.github.io/nodify
MIT License
1.27k stars 205 forks source link

[Question] Draggable arrowheads, is it possible? #87

Closed koskiniko closed 4 months ago

koskiniko commented 6 months ago

I'm trying to figure out how to make edits to existing connections, so that user could just drag from an arrowhead and change the target of the connection. Currently I need to delete the existing connection and start a new connection from the source.

Unless I'm missing something?

image

miroiu commented 6 months ago

Hi. I can't suggest a good solution for implementing this functionality and I also believe that it may not be possible without heavy modifications to the library.

The way it works right now is that each connection (wire) has a Source and a Target point. Each of these two points is usually bound to and updated by a connector's Anchor point.

Nonetheless, I can think of two approaches:

  1. Bind the Target point of the connection to the mouse location on the mouse down event. Then, find the Connector at the mouse location on the mouse up event and bind the connection to its Anchor.
  2. Remove the original connection and start a new PendingConnection by raising the Connector.PendingConnectionStartedEvent on the mouse down event and Connector.PendingConnectionDragEvent on the mouse move event. To complete the connection, the Connector.PendingConnectionCompletedEvent must be raised on mouse up event.
miroiu commented 4 months ago

There's no straightforward way of implementing this. Please feel free to reopen the issue if you need more information.