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

Viewport-covering DockSpace capturing mouse input on viewport edge #4042

Closed
Bizzarrus opened this issue Apr 14, 2021 · 1 comment
Closed

Comments

@Bizzarrus
Copy link

Version/Branch of Dear ImGui:

Version: 1.80
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: Custom
Compiler: MSVC
Operating System: Windows

My Issue/Question:

In our tools, we create a DockSpace that covers the whole main viewport, with the PassthruCentralNode flag. If no windows are open (and therefore, the DockSpace is empty), mouse input is passed through the dock space and to our application as expected. However, if the mouse cursor is at the very edge of the main viewport, io.WantCaptureMouse becomes true, so the mouse input is eaten by Dear ImGui and not sent to the application anymore. The Metrics/Debug window shows that it's actually a DockSpace that takes the mouse input. This behaviour is unexpected and highly confusing to our QA, as there's no visible UI that would block the mouse input from getting to the application.

So, my question is: Is this a bug, or actually expected behaviour, or are we just doing something wrong?

Screenshots/Video

image
(The image was taken right after clicking on the far left edge of the viewport, it was highlighting the "Dockspace/Dockspace_..." node in the metrics window as soon as I clicked. Unfortunately, my screenshot tool doesn't include the mouse cursor in the screenshot. There was no other window visible/opened other than the metrics window)

Standalone, minimal, complete and verifiable example:

static ImGuiID dockspace_id = ImGui::GetID( "GGG_Dockspace" );
static bool reset_layout = true;

ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->GetWorkPos());
ImGui::SetNextWindowSize(viewport->GetWorkSize());
ImGui::SetNextWindowViewport(viewport->ID);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
ImGui::Begin("Dockspace", nullptr, ImGuiWindowFlags_NoWindow | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoDocking);
ImGui::PopStyleVar(3);

if(reset_layout)
{
    reset_layout = false;
    ImGui::DockBuilderRemoveNode( dockspace_id );
    ImGui::DockSpace( dockspace_id, ImVec2( 0, 0 ), ImGuiDockNodeFlags_PassthruCentralNode );
    ImGui::DockBuilderSetNodeSize(dockspace_id, ImGui::GetMainViewport()->GetWorkSize());

    // Various calls to ImGui::DockBuilderSplitNode and ImGui::DockBuilderDockWindow

    ImGui::DockBuilderFinish(dockspace_id);
}
else
{
    ImGui::DockSpace( dockspace_id, ImVec2( 0, 0 ), ImGuiDockNodeFlags_PassthruCentralNode );
}

ImGui::End();

// Committing various other windows
@ocornut
Copy link
Owner

ocornut commented Apr 14, 2021 via email

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