hoffstadt / hoffstadt/DearPyGui

Be able to get mouse position within Node Editor

Open
#2,164 14 comments 2 reactions 0 assignees View on GitHub
state: pending type: improvement
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

**Is your feature request related to a problem? Please describe.**

I am trying to make a Drag and Drop node editor, where I have a sidebar from which I can select nodes to add to a Node Editor area:

![sc1](https://github.com/hoffstadt/DearPyGui/assets/20630819/dbe81e6e-3b0d-42d2-aa60-1cf3515fe77a)

I have implemented already the drag and drop functionality. However, dragged nodes appear in a wrong position (and not where the drop callback happens).

This is due to how the drop callback works: I just get the mouse position using `dpg.get_mouse_pos(local=False)`, and create a new Node in the Node Editor using that position.

The issue here is that positioning within the Node Editor work differently (it has its own coordinate system, which allows for panning through the editor by clicking the mouse wheel).

You can see the issue here:

![drag_demo](https://github.com/hoffstadt/DearPyGui/assets/20630819/1197e584-fc71-4e69-9209-c1867dffdaa8)

**Describe the solution you'd like**

A simple way to get the mouse position within the Node Editor would solve the issue (using the same positioning system that `dpg.get_item_pos(some_node_item)`).

**Describe alternatives you've considered**

The only alternative I can think of is to always create new nodes in position `[0,0]`, but then drag and drop would not make sense.

**Additional context**
Nothing noteworthy

Thank you! I really like the library.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.