summaryrefslogtreecommitdiffstats
path: root/Imgui/src/ImGuiImplWin32.cpp
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-09-29 20:21:31 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-09-29 20:21:31 +0000
commit2943ac63fffc535ddac4415870223c73d35ec4ff (patch)
tree5a16d25b4cfabb2fb9eaff2d7f940f0264502ba2 /Imgui/src/ImGuiImplWin32.cpp
parentImgui implementation: fixed few Vulkan issues (diff)
downloadDiligentTools-2943ac63fffc535ddac4415870223c73d35ec4ff.tar.gz
DiligentTools-2943ac63fffc535ddac4415870223c73d35ec4ff.zip
Imgui win32 impl: updated event hanlding to avoid modifications to imgui
Diffstat (limited to 'Imgui/src/ImGuiImplWin32.cpp')
-rw-r--r--Imgui/src/ImGuiImplWin32.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/Imgui/src/ImGuiImplWin32.cpp b/Imgui/src/ImGuiImplWin32.cpp
index 647fde3..58f3f6e 100644
--- a/Imgui/src/ImGuiImplWin32.cpp
+++ b/Imgui/src/ImGuiImplWin32.cpp
@@ -59,7 +59,37 @@ void ImGuiImplWin32::NewFrame()
LRESULT ImGuiImplWin32::Win32_ProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- return ImGui_ImplWin32_WndProcHandler(hwnd, msg, wParam, lParam);
+ if (ImGui::GetCurrentContext() == NULL)
+ return 0;
+
+ auto res = ImGui_ImplWin32_WndProcHandler(hwnd, msg, wParam, lParam);
+
+ ImGuiIO& io = ImGui::GetIO();
+ switch (msg)
+ {
+ case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK:
+ case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK:
+ case WM_MBUTTONDOWN: case WM_MBUTTONDBLCLK:
+ case WM_XBUTTONDOWN: case WM_XBUTTONDBLCLK:
+ case WM_LBUTTONUP:
+ case WM_RBUTTONUP:
+ case WM_MBUTTONUP:
+ case WM_XBUTTONUP:
+ case WM_MOUSEWHEEL:
+ case WM_MOUSEHWHEEL:
+ return io.WantCaptureMouse ? 1 : 0;
+
+ case WM_KEYDOWN:
+ case WM_SYSKEYDOWN:
+ case WM_KEYUP:
+ case WM_SYSKEYUP:
+ case WM_CHAR:
+ return io.WantCaptureKeyboard ? 1 : 0;
+ case WM_SETCURSOR:
+ return res;
+ }
+
+ return res;
}
}