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

How to only allow docking in main viewport (i.e., disable docking inside windows) #8462

Open
ksdhans opened this issue Mar 5, 2025 · 2 comments
Labels

Comments

@ksdhans
Copy link

ksdhans commented Mar 5, 2025

Version/Branch of Dear ImGui:

1.91.8-docking

Back-ends:

rlImGui

Compiler, OS:

Windows 10 + MSVC 2019

Full config/build information:

No response

Details:

By default Dear ImGUI allows any window to dock inside any other window. How can I disable docking inside one (or all windows)? What I'd like to achieve, is to allow windows to dock inside the main viewport, but NOT inside each other.

The ImGuiWindowFlags_NoDocking disables docking for a window entirely.

How can I allow a window to be able to dock, but NOT allow any window to dock inside it?

@GamingMinds-DanielC
Copy link
Contributor

I can't think of any benefit from disabling the possibility to dock in secondary viewports. If you yourself don't like it, you can just not use this optional functionality. But why would you want to take that away from the users of your application?

As far as I know, limiting docking like that is currently not possible. You would have to alter ImGui sources for that. If you want to do that, look for calls to BeginDockableDragDropTarget() and make it depend on being in the main viewport.

@ocornut ocornut added the docking label Mar 5, 2025
@ksdhans
Copy link
Author

ksdhans commented Mar 5, 2025

"I can't think of any benefit from disabling the possibility to dock in secondary viewports."

It can be confusing to users if any window can be docked inside any other window. This is especially true if your users are less tech savvy.

I don't know of any app that allows unrestricted dock any window into any other window. For example, VS Code restricts where things can be dragged and dropped.

"As far as I know, limiting docking like that is currently not possible. You would have to alter ImGui sources for that."
It seems to be possible, albeit overly complicated: #3492

The solutions on that page use the unstable APIs inside imgui_internal.h. I was hoping that there would be a way that uses the stable API.

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

No branches or pull requests

3 participants