From 235cca4f971cda95d2b14c2d599e98aac6a0ca5e Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 27 May 2015 23:24:39 +0100 Subject: [PATCH] Fix to allow opening popup from a left-click on void or another window (because left-click would normally override focus immediately) (#126) Neither appears to be really useful frankly. --- imgui.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 96920a33..735b5d33 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2377,16 +2377,19 @@ void ImGui::Render() // Click to focus window and start moving (after we're done with all our widgets) if (g.ActiveId == 0 && g.HoveredId == 0 && g.IO.MouseClicked[0]) { - if (g.HoveredRootWindow != NULL) + if (!(g.FocusedWindow && !g.FocusedWindow->WasActive && g.FocusedWindow->Active)) // Unless we just made a popup appear { - IM_ASSERT(g.MovedWindow == NULL); - g.MovedWindow = g.HoveredWindow; - SetActiveId(g.HoveredRootWindow->MoveID, g.HoveredRootWindow); - } - else if (g.FocusedWindow != NULL) - { - // Clicking on void disable focus - FocusWindow(NULL); + if (g.HoveredRootWindow != NULL) + { + IM_ASSERT(g.MovedWindow == NULL); + g.MovedWindow = g.HoveredWindow; + SetActiveId(g.HoveredRootWindow->MoveID, g.HoveredRootWindow); + } + else if (g.FocusedWindow != NULL) + { + // Clicking on void disable focus + FocusWindow(NULL); + } } }