hoffstadt / hoffstadt/DearPyGui

drag frameless window bug

Open
#2,410 2 comments 1 reaction 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

## Version of Dear PyGui

Version: 2.0.0
Operating System: Windows 11

## My Issue/Question

hi there I have a code for a frameless window and I needed to use input in it. but after interacting with the input, when I try to drag the window, it begins to move endlessly in the direction in which I drag it.

## To Reproduce

Steps to reproduce the behavior:
1. Interact with input
2. Drag the window
4. See bug

## Expected behavior

i need normal window drag behavior after interacting with input

## Video

https://github.com/user-attachments/assets/a1a36bc3-fc10-4d0c-945f-56a26b178e00

## example

```python
import dearpygui.dearpygui as ui
import os

class ui_settings:
size = (475, 415)
ui_dragging = False
tabs = [
"tab_1",
#"tab_2",
#"tab_3",
"settings_tab",
]

class scaling:
section_width = ui_settings.size[0] - 20
section_height = ui_settings.size[1] - 75

button_size = (115, 25)
spacing_offset = 10

ui.create_context()

viewport = ui.create_viewport(title="window_title", width=ui_settings.size[0], height=ui_settings.size[1], decorated=False, resizable=True,max_width=475,max_height=415)

ui.setup_dearpygui()

with ui.window(label="example", tag="main", width=ui_settings.size[0], height=ui_settings.size[1], no_collapse=True, no_move=True, no_resize=True, on_close=lambda: os._exit(0)) as win:
ui.add_input_text()

def lerp(a, b, t):
return a + (b - a) * t

def is_dragging(_, data):
if ui.is_mouse_button_down(0):
y = data[1]
if -2 <= y <= 19:
ui_settings.ui_dragging = True
else:
ui_settings.ui_dragging = False

def drag_logic(_, data):
if ui_settings.ui_dragging:
pos = ui.get_viewport_pos()
x = data[1]
y = data[2]

current_spacing_offset = pos[0]
current_y = pos[1]

speed = float(0.1)
interpolated_x = lerp(current_spacing_offset, pos[0] + x, speed)
interpolated_y = lerp(current_y, pos[1] + y, speed)

ui.configure_viewport(viewport, x_pos=interpolated_x, y_pos=interpolated_y)

with ui.handler_registry():
ui.add_mouse_drag_handler(0, callback=drag_logic)
ui.add_mouse_move_handler(callback=is_dragging)

ui.show_viewport()
ui.start_dearpygui()
ui.destroy_context()
```

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.