From e1a7daf38a1de97d69bf6288782c91e29fed9b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 20 Dec 2014 19:07:01 -0800 Subject: [PATCH] Win: Capture mouse when mouse button is down. --- examples/common/entry/entry_windows.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/examples/common/entry/entry_windows.cpp b/examples/common/entry/entry_windows.cpp index aa3b19dc..9af4390e 100644 --- a/examples/common/entry/entry_windows.cpp +++ b/examples/common/entry/entry_windows.cpp @@ -306,6 +306,18 @@ namespace entry tinystl::string m_title; }; + static void mouseCapture(HWND _hwnd, bool _capture) + { + if (_capture) + { + SetCapture(_hwnd); + } + else + { + ReleaseCapture(); + } + } + struct Context { Context() @@ -699,6 +711,7 @@ namespace entry case WM_LBUTTONUP: case WM_LBUTTONDBLCLK: { + mouseCapture(_hwnd, _id == WM_LBUTTONDOWN); int32_t mx = GET_X_LPARAM(_lparam); int32_t my = GET_Y_LPARAM(_lparam); m_eventQueue.postMouseEvent(findHandle(_hwnd), mx, my, m_mz, MouseButton::Left, _id == WM_LBUTTONDOWN); @@ -709,16 +722,18 @@ namespace entry case WM_MBUTTONUP: case WM_MBUTTONDBLCLK: { + mouseCapture(_hwnd, _id == WM_MBUTTONDOWN); int32_t mx = GET_X_LPARAM(_lparam); int32_t my = GET_Y_LPARAM(_lparam); m_eventQueue.postMouseEvent(findHandle(_hwnd), mx, my, m_mz, MouseButton::Middle, _id == WM_MBUTTONDOWN); } break; - case WM_RBUTTONUP: case WM_RBUTTONDOWN: + case WM_RBUTTONUP: case WM_RBUTTONDBLCLK: { + mouseCapture(_hwnd, _id == WM_RBUTTONDOWN); int32_t mx = GET_X_LPARAM(_lparam); int32_t my = GET_Y_LPARAM(_lparam); m_eventQueue.postMouseEvent(findHandle(_hwnd), mx, my, m_mz, MouseButton::Right, _id == WM_RBUTTONDOWN);