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

A window with popup=True is positioned incorrectly #1975

Closed
v-ein opened this issue Dec 11, 2022 · 2 comments · Fixed by #2003
Closed

A window with popup=True is positioned incorrectly #1975

v-ein opened this issue Dec 11, 2022 · 2 comments · Fixed by #2003
Labels
state: pending not addressed yet type: bug bug

Comments

@v-ein
Copy link
Contributor

v-ein commented Dec 11, 2022

Version of Dear PyGui

Version: 1.8.0
Operating System: Windows 10

My Issue/Question

When a window with popup=True and show=False gets displayed for the first time, it is positioned in the top left corner of the viewport, whereas on subsequent show_item() calls it appears at the mouse cursor position. I'm talking about dpg.window() here, not about dpg.popup().

To Reproduce

Steps to reproduce the behavior:

  1. Run the example below
  2. Click on 'Click me!'
  3. Notice that the popup is displayed in the top left corner of the viewport.
  4. Dismiss the popup by clicking somewhere else.
  5. Click on 'Click me!' again.
  6. Notice that from now on, the popup shows up at the mouse cursor.

Expected behavior

I'd expect that the first call to dpg.show_item() for a popup=True window to position the window at the mouse cursor, just like subsequent calls do.

BTW that's the way dpg.popup() works, and it uses dpg.window(popup=True, show=False) internally, so it would only be reasonable to have the same behavior in both cases.

Screenshots/Video

popup1
popup2

Standalone, minimal, complete and verifiable example


dpg.create_context()
dpg.create_viewport(title="Test", width=500, height=400)

with dpg.window(pos=(100, 100), width=300, height=100):
    with dpg.window(popup=True, show=False, min_size=(1, 1)) as popup:
        dpg.add_selectable(label="This is a popup")

    dpg.add_button(label="Click me!", callback=lambda: dpg.show_item(popup))

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
@v-ein v-ein added state: pending not addressed yet type: bug bug labels Dec 11, 2022
@v-ein
Copy link
Contributor Author

v-ein commented Dec 11, 2022

As a matter of fact, I do have a fix for the issue. Shall I open a PR for it?

@bandit-masked
Copy link
Collaborator

Yes, please submit a PR.

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

Successfully merging a pull request may close this issue.

2 participants