Drawing live line on Canvas #322
Answered
by
JaggerJo
matthewcrews
asked this question in
Q&A
Replies: 2 comments 13 replies
-
You need to capture the pointer if you want to get movements even when it leaves the element. |
Beta Was this translation helpful? Give feedback.
12 replies
-
I've never tried doing anything like this myself, but - does https://github.com/wieslawsoltes/NodeEditor do the sort of thing that you're trying? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have been developing a simple tool for dragging and connecting blocks. I've added the ability to click on an output node (yellow button on the right) and I'm drawing a red line to wherever the cursor is pointing to. The problem is that it only updates to the cursor's position when it's inside another button on the screen.
Here's a snapshot of the line drawing to where the cursor currently is:

If I move the cursor outside of the buttons I get this though:

Notice how the cursor has moved to the right but the green line is no longer tracking the cursor. I tried adding an event handler for
onPointerMoved
to the Canvas but that doesn't seem to be working:You can see the full code at the link below. To recreate the issue, clone the repo, run the program, click on the right yellow button, and move the cursor around.
Code for Line Drawing:
https://github.com/matthewcrews/AvaloniaDragAndDrop/blob/5c1899517061d35da9ad859fc922e3250871f2d1/Program.fs#L199
Beta Was this translation helpful? Give feedback.
All reactions