1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-12 02:00:58 +01:00

Comments about mouse setup and clearing HoveredWindow when mouse down isn't owned by imgui (will affect some future hovered test and drag'n drop patterns) (#143, #1382, #1392)

This commit is contained in:
omar 2017-10-25 11:01:41 +02:00
parent 4faf99eff5
commit daef33e268

View File

@ -2382,7 +2382,7 @@ void ImGui::NewFrame()
g.ModalWindowDarkeningRatio = 0.0f; g.ModalWindowDarkeningRatio = 0.0f;
} }
// Are we using inputs? Tell user so they can capture/discard the inputs away from the rest of their application. // Update the WantCaptureMouse/WantCAptureKeyboard flags, so user can capture/discard the inputs away from the rest of their application.
// When clicking outside of a window we assume the click is owned by the application and won't request capture. We need to track click ownership. // When clicking outside of a window we assume the click is owned by the application and won't request capture. We need to track click ownership.
int mouse_earliest_button_down = -1; int mouse_earliest_button_down = -1;
bool mouse_any_down = false; bool mouse_any_down = false;
@ -2392,7 +2392,7 @@ void ImGui::NewFrame()
g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty()); g.IO.MouseDownOwned[i] = (g.HoveredWindow != NULL) || (!g.OpenPopupStack.empty());
mouse_any_down |= g.IO.MouseDown[i]; mouse_any_down |= g.IO.MouseDown[i];
if (g.IO.MouseDown[i]) if (g.IO.MouseDown[i])
if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[mouse_earliest_button_down] > g.IO.MouseClickedTime[i]) if (mouse_earliest_button_down == -1 || g.IO.MouseClickedTime[i] < g.IO.MouseClickedTime[mouse_earliest_button_down])
mouse_earliest_button_down = i; mouse_earliest_button_down = i;
} }
bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down]; bool mouse_avail_to_imgui = (mouse_earliest_button_down == -1) || g.IO.MouseDownOwned[mouse_earliest_button_down];
@ -2407,6 +2407,7 @@ void ImGui::NewFrame()
g.OsImePosRequest = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default g.OsImePosRequest = ImVec2(1.0f, 1.0f); // OS Input Method Editor showing on top-left of our window by default
// If mouse was first clicked outside of ImGui bounds we also cancel out hovering. // If mouse was first clicked outside of ImGui bounds we also cancel out hovering.
// FIXME: For patterns of drag and drop between "application" and "imgui" we may need to rework/remove this test (first committed 311c0ca9 on 2015/02)
if (!mouse_avail_to_imgui) if (!mouse_avail_to_imgui)
g.HoveredWindow = g.HoveredRootWindow = NULL; g.HoveredWindow = g.HoveredRootWindow = NULL;