thedmd / imgui-node-editor

Node Editor built using Dear ImGui
MIT License
3.73k stars 550 forks source link

Strange mouse move behavior, need an advice #304

Closed leavittx closed 2 months ago

leavittx commented 2 months ago

Hi there! It's been pleasure using imgui-node-editor library for me. Everything works fine in the code that was written using the master version with smooth zoom. Right now I'm in the process of rewriting my app using same imgui-node-editor version (need to do it for various reasons).

I got the basic stuff done already - and all of the sudden the nodes movement with mouse seems to be broken.

2 problems so far:

  1. After adding a node, whereever the mouse cursor is, when I press the LMB, the node is being moved around, even though it's not hovered. Even when I add more nodes, mouse moving with LMB pressed moves the first node.
  2. Node deletion is broken. When I press DELETE, ed::BeginDelete() returns true, but ed::QueryDeletedNode always returns false However it's possible to select a node with a click (it's outline changes to yellow)
  3. Link deletion is broken. When I move mouse on top of the link, it's being hovered by blue color, however when I click, it's not being selected (no yellow color), and when I press DELETE, nothing happens (same problem as 2)

https://github.com/user-attachments/assets/96a9a44a-3f78-4fb2-9138-60465db2c19a

All the basic setup / node editor processing code seems to be correct. Have no idea how to debug in this situation (the library code is quite complex - any tip for where to look is appreciated!)

I will post my full code within next couple of days if I fail to find the problem - right now maybe it's possible to say something by the video. Thanks

leavittx commented 2 months ago

Ok, solved it. I've used 0 node id, i.e. ed::BeginNode(0); which apparently was a bad idea, and lead to these confusing bugs. So ID should be always more or equal to 1. Maybe that information would be useful for somebody in the future if same bugs occur