From e585f3b3463660be482a36fc89c073f0530ad44c Mon Sep 17 00:00:00 2001 From: saschawillems Date: Thu, 5 Oct 2017 21:22:29 +0200 Subject: [PATCH] Use new mouse moved event to handle imGui window mouse capture --- imgui/main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/imgui/main.cpp b/imgui/main.cpp index 7ef5d66d..158b675c 100644 --- a/imgui/main.cpp +++ b/imgui/main.cpp @@ -779,13 +779,9 @@ public: io.DisplaySize = ImVec2((float)width, (float)height); io.DeltaTime = frameTimer; - // todo: Android touch/gamepad, different platforms -#if defined(_WIN32) io.MousePos = ImVec2(mousePos.x, mousePos.y); - io.MouseDown[0] = (((GetKeyState(VK_LBUTTON) & 0x100) != 0)); - io.MouseDown[1] = (((GetKeyState(VK_RBUTTON) & 0x100) != 0)); -#else -#endif + io.MouseDown[0] = mouseButtons.left; + io.MouseDown[1] = mouseButtons.right; draw(); @@ -797,6 +793,13 @@ public: { updateUniformBuffers(); } + + virtual void mouseMoved(double x, double y, bool &handled) + { + ImGuiIO& io = ImGui::GetIO(); + handled = io.WantCaptureMouse; + } + }; VULKAN_EXAMPLE_MAIN()