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

Dockspace popup menu #3398

Closed
timeinpixels opened this issue Aug 9, 2020 · 6 comments
Closed

Dockspace popup menu #3398

timeinpixels opened this issue Aug 9, 2020 · 6 comments

Comments

@timeinpixels
Copy link

Is there a way to create a popup menu in an empty Dockspace?
I need a quick right-click context menu with an option to add new window, but the context menu should be available only in an empty dockspace "behind" all the windows.

ocornut added a commit that referenced this issue Aug 10, 2020
…asily detecting e.g. hovering an empty node. (#3398)
@ocornut
Copy link
Owner

ocornut commented Aug 10, 2020

Hello,

It took me a while to answer this question.
I pushed acf043a and 85a661d and you should be able to poll for that specific empty node hovering using imgui_internal.h now:

#include "imgui_internal.h"
[...]
ImGuiContext& g = *GImGui;
bool is_dockspace_hole_hovered = g.HoveredDockNode && g.HoveredDockNode->IsEmpty() && ImGui::DockNodeGetRootNode(g.HoveredDockNode)->ID == dockspace_id;

From there you should use OpenPopup() + BeginPopup(), probably like:

if (is_dockspace_hole_hovered && IsMouseReleased(1))
   OpenPopup(....)
if (BeginPopup(...)
{

(Note that we've been working on a change for #3291, which would eventually facilitate adding custom button in dock node that have tab bar, but not directly solving your specific case).

@timeinpixels
Copy link
Author

Thanks! Works like a charm!

@ocornut
Copy link
Owner

ocornut commented Aug 11, 2020

Great. I'll close this for now!

@ocornut ocornut closed this as completed Aug 11, 2020
ocornut added a commit that referenced this issue Aug 25, 2020
…rrectly over-relied on g.HoveredDockNode when making change for #3398)

Essentially undo part of 85a661d (#3398) + ref cf31254 (#3420)
@ocornut
Copy link
Owner

ocornut commented Aug 25, 2020

When I applied this change I thought it would be good if actual docking relied on g.HoveredDockNode which actually broke quite a few things. It's possible to set docking/payload filter and therefore on overlapping docking node the actual docking target is not necessarily the 'top-most' docking node. Applied a fix now while preserving g.HoveredDockNode as an available mechanism for some operations such as the one discussed above.

@timeinpixels
Copy link
Author

Hey Omar,

Just updated to the latest version and noticed that now HoveredDockNode is gone and there's one called DebugHoveredDockNode - is the behaviour the same, or I should make it work differently now...?
Seems to be working OK.

@ocornut
Copy link
Owner

ocornut commented Sep 5, 2022

It is the same field, it was renamed as the field was only meant to be used for debugging (actual docking can't use this as there are variety of docking filters behaving dynamically).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants