Nelarius / imnodes

A small, dependency-free node editor for dear imgui
MIT License
2.01k stars 244 forks source link

Support for deselecting a node, or not selecting a node when an input becomes active #54

Closed thepaperpilot closed 3 years ago

thepaperpilot commented 4 years ago

Currently, having an active attribute selects the node, which prevents users from dragging things in an attribute, because it drags the node instead. For example, focusing an input field in an attribute will prevent the user from dragging to select text within the field, and if its multiline the scrollbar cannot be dragged with the mouse.

To solve this, a flag could be added to attributes to prevent them from selecting the node when becoming active, or a method could be added to deselect a node, and that could be called when IsAnyAttributeActive returns true.

edit: If you end up adding the method to deselect the node (or all nodes), it could also be used to, e.g., deselect all nodes after deleting them. That is, if I delete all selected nodes, it would be nice if imnodes didn't still return those IDs in the next GetSelectedNodes call

Nelarius commented 3 years ago

Hi @thepaperpilot ! Sorry about the long response time.

Your suggestion is a good one, it's a bit of an oversight to not allow active item manipulation to be honest 😄 Do you think there are situations where you would want the current behaviour? Something like AttributeFlags_AllowActiveItemInteraction (or something similar) could be added to the AttributeFlags enum. But node selection could also be inhibited whenever there is an active item, without the ability to specify it on a node-by-node basis.

thepaperpilot commented 3 years ago

That's a good point, a flag may be unnecessary and it probably makes more sense to just not select the node when there is an active item.