hoffstadt / DearPyGui

Dear PyGui: A fast and powerful Graphical User Interface Toolkit for Python with minimal dependencies
https://dearpygui.readthedocs.io/en/latest/
MIT License
12.62k stars 669 forks source link

Add methods 'set_selected_nodes' and 'set_selected_links' for setting selected items in node graph. #2353

Open Tomislaw opened 4 days ago

Tomislaw commented 4 days ago

As name suggest, It would be great to have methods for selecting node editor items programmatically.

I tried to implement node duplication callback, and I would want to mark new duplicated nodes as selected. Unfortunately, I was unable to achieve this result.

v-ein commented 4 days ago

Alternatively, we could add selected to the node or link config (and change it with configure_item). Then, use ImNodes::SelectNode() to change it, and ImNodes::IsNodeSelected() to update it from ImNodes...

However, at the moment, ImNodes::IsNodeSelected() is slow (it performs a linear search in std::vector), so it might be better to use dedicated functions (set/get_selected_nodes) rather than a per-node config field.