vurtun / nuklear

A single-header ANSI C gui library
13.69k stars 1.11k forks source link

behavior of demo/node_editor.c #706

Open wtholliday opened 6 years ago

wtholliday commented 6 years ago

I was trying out the node_editor demo and noticed that when I position two nodes on top of each other, dragging will sometimes move the one behind.

This seems to be a consequence of the event-handling order being the same as the draw order. In general, it seems an immediate mode gui that returns booleans indicating if something was clicked/dragged would have the problem of the widget drawn in the back (first) getting the first crack at events.

Also, when dragging a node over another node, sometimes it will switch to dragging the other node during the drag.

How would one go about fixing these things?

EvilPudding commented 6 years ago

I reported something similar in #657 which @vurtun fixed, you can check the commits to see if it applies.

I too have been playing with the node editor, and it also happens that if you are dragging a window and go over a node output, you start linking that output. This seems like it could be easily fixed by keeping track of which window is being grabbed and not propagating any other mouse events while dragging. This can also be fixed on the node_editor code, separate the while loop into two loops, one for drawing, one for dragging and make the windows not draggable so you can override the event.