Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drag frameless window bug #2410

Open
gen1337 opened this issue Nov 2, 2024 · 0 comments
Open

drag frameless window bug #2410

gen1337 opened this issue Nov 2, 2024 · 0 comments
Labels
state: pending not addressed yet type: bug bug

Comments

@gen1337
Copy link

gen1337 commented Nov 2, 2024

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
  3. See bug

Expected behavior

i need normal window drag behavior after interacting with input

Video

2024-11-02.18-12-33.mp4

example

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()
@gen1337 gen1337 added state: pending not addressed yet type: bug bug labels Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: pending not addressed yet type: bug bug
Projects
None yet
Development

No branches or pull requests

1 participant