Knowing whether the cursor is over UI during drag and drop
Version/Branch of Dear ImGui:
Version: v1.87 WIP Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: custom, Win32 + D3D12 Compiler: MSVC 2022 Operating System: Windows 10
My Issue/Question:
I would like to drag from an imgui button to either another imgui control or an object in my scene. While not in a drag, I can tell whether the cursor is currently over imgui UI by looking at io.WantCaptureMouse, but during a drag that value is true whether or not I'm hovering over imgui UI, so when a drop happens I can't differentiate whether the user tried to drop on a UI control or on the scene object covered by the intentionally-transparent window. Ideally, I would like to be able to differentiate between both scenarios so that a drop event over a UI element gets ignored or routed to the UI element, otherwise a drop over a window can fall-through to the scene / world object behind that window.
Screenshots/Video
N/A
Standalone, minimal, complete and verifiable example:
You can add the code below to a window, drag the "Drag Handler Grip" button, and watch as WantCaptureMouse remains true even as the cursor leaves the window. I believe this is the correct behavior for WantCaptureMouse, but could there be an orthogonal way of checking whether the cursor is over UI?
using namespace ImGui;
const auto& IO = GetIO();
{
Text("WantCaptureMouse: ");
SameLine();
Text(IO.WantCaptureMouse ? "True" : "False");
}
Button("Drag Handler Grip");
if(BeginDragDropSource())
{
EndDragDropSource();
}