rokups / ImNodes

Node graph implementation for Dear ImGui. Used in https://github.com/rokups/rbfx
MIT License
656 stars 57 forks source link

Hitting delete with inactive Canvas deletes selected node #38

Closed sphaero closed 2 years ago

sphaero commented 2 years ago

Just try the sample.cpp application:

sphaero commented 2 years ago

This seems a trivial problem to fix but I have not found the right code yet to skip the delete if the window is not active/hovered/nav???/selected

sphaero commented 2 years ago

related code: https://github.com/rokups/ImNodes/blob/581525381beb5fa26dd46e9ea42216d4dbbff5c7/sample.cpp#L177

sphaero commented 2 years ago

if (node->Selected && ImGui::IsKeyPressedMap(ImGuiKey_Delete) && ImGui::IsWindowFocused())

Seems a solution but it feels like this should be done differently? Anyone?

rokups commented 2 years ago

Looks good to me.

sphaero commented 2 years ago

I'll create a PR. However it feels like this should be handled automatically somehow. I've not experienced this with builtin widgets and windows.

rokups commented 2 years ago

Widgets do not handle key presses, user application does. This is why its in sample.cpp.