hoffstadt / hoffstadt/DearPyGui

Drop doesn't work in version 2.3

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

Description

### Dear PyGui version:

2.3

### Python version:

3.8.5

### Operating system:

windows 11

### My issue/question:

I used the same method to drag and move controls in 2.0, and in 2.3 and 2.3. I found it didn't work, and I couldn't figure out the reason. It certainly works when it is not dynamically created through multiple functions.

### Steps to reproduce:

run code

### Expected behavior:

Running this code with version 2.0 or below will allow you to move the button normally, but button 1 and button 2.3 will not move; it shows no reaction.

### Screenshots:

N/A

### Standalone, minimal, complete and verifiable example:

```python
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title='123')
print(dpg.get_dearpygui_version())

def set_pos(a, b, c):
pos = dpg.get_item_pos(c)
print("set_pos")

def drop(a, b, c):
print("droping")
if dpg.does_item_exist(c):
dpg.set_item_pos(c, dpg.get_mouse_pos())

def move_item(a, b, tag):

print("tag",tag)
x, y = dpg.get_item_pos(tag)
foo = dpg.get_item_parent(tag)
dpg.add_button(width=100, height=100, label=("drop_me"), user_data=tag,
pos=[x - 10, y - 10], callback=set_pos, drag_callback=drop,
parent=foo, tag="drop_move")

with dpg.drag_payload(parent="drop_move", user_data=tag):
dpg.add_text(tag)

def popup(tag):
with dpg.popup(tag, mousebutton=dpg.mvMouseButton_Right, modal=False,
tag=f"popup_{tag}"):
dpg.add_text(f'[{"item_type"}] {tag}')
dpg.add_text("Current_control")
dpg.add_text(tag, tag=f"popup_{tag}_text")
dpg.add_separator()
with dpg.group(horizontal=True, width=140, height=30):
dpg.add_button(label="move_item", user_data=tag, callback=move_item)

with dpg.window(label="Tutorial",tag="main_window_1",horizontal_scrollbar=True,no_move=True,width=800,height=600):
dpg.add_text("xxx", tag="tooltip_parent",)

dpg.add_button(label="but1", tag="drop_1")
popup("drop_1")

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
```

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.