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

on_close has no effect for popup windows #2372

Open
axeldavy opened this issue Aug 1, 2024 · 1 comment
Open

on_close has no effect for popup windows #2372

axeldavy opened this issue Aug 1, 2024 · 1 comment
Labels
state: pending not addressed yet type: bug bug

Comments

@axeldavy
Copy link

axeldavy commented Aug 1, 2024

Version of Dear PyGui

Version: 1.11.1
Operating System: Arch Linux

My Issue/Question

I want to open a popup window on top of a plot in response to a click, and I need to be notified when the popup is closed.

A popup is closed by clicking outside the popup.

With current dpg, the on_close callback is never called for popup windows.

To Reproduce

import dearpygui.dearpygui as dpg
import time

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

def on_close_handler(sender, data):
    print("In on_close_handler")


with dpg.window(tag="Primary Window"):
    dpg.add_text("Hello")
    with dpg.window(popup=True, autosize=True, on_close=on_close_handler):
        dpg.add_text("Click outside me")


dpg.show_viewport()
dpg.set_primary_window("Primary Window", True)
dpg.start_dearpygui()
dpg.destroy_context()

In this example, clicking outside the popup will never call on_close_handler.

In the C++ code, we can see that there is code to handle on_close for modal windows, but not for popups. Copying the code for modal windows seems to work in my case. With that change, clicking outside the popup does trigger on_close. However I didn't find a way to properly 'close' the popup in response to some interaction inside the popup (delete_item doesn't trigger on_close, neither show=False). In this case my workaround was to called the on_close handler in the concerned handlers to complement clicking outside the popup.

@axeldavy axeldavy added state: pending not addressed yet type: bug bug labels Aug 1, 2024
@v-ein
Copy link
Contributor

v-ein commented Aug 1, 2024

I have a fix for this, but waiting for #2275 (I decided to "freeze" all my fixes until that giant PR gets merged).

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

2 participants