ソースを参照

Capture/release window in DX9 implementation

This helps a lot when the user drags a slider but carries the cursor offscreen before releasing the button - without the capturing, the slider will "stick" to the mouse cursor even after the button has been released. (This should generally be added to all Windows implementations - I won't mind doing it if you think it's a good idea.)
Gargaj 8 年 前
コミット
839067fda9
1 ファイル変更6 行追加0 行削除
  1. 6 0
      examples/directx9_example/imgui_impl_dx9.cpp

+ 6 - 0
examples/directx9_example/imgui_impl_dx9.cpp

@@ -177,21 +177,27 @@ IMGUI_API LRESULT ImGui_ImplDX9_WndProcHandler(HWND, UINT msg, WPARAM wParam, LP
     switch (msg)
     switch (msg)
     {
     {
     case WM_LBUTTONDOWN:
     case WM_LBUTTONDOWN:
+        SetCapture( hWnd );
         io.MouseDown[0] = true;
         io.MouseDown[0] = true;
         return true;
         return true;
     case WM_LBUTTONUP:
     case WM_LBUTTONUP:
+        ReleaseCapture();
         io.MouseDown[0] = false;
         io.MouseDown[0] = false;
         return true;
         return true;
     case WM_RBUTTONDOWN:
     case WM_RBUTTONDOWN:
+        SetCapture( hWnd );
         io.MouseDown[1] = true;
         io.MouseDown[1] = true;
         return true;
         return true;
     case WM_RBUTTONUP:
     case WM_RBUTTONUP:
+        ReleaseCapture();
         io.MouseDown[1] = false;
         io.MouseDown[1] = false;
         return true;
         return true;
     case WM_MBUTTONDOWN:
     case WM_MBUTTONDOWN:
+        SetCapture( hWnd );
         io.MouseDown[2] = true;
         io.MouseDown[2] = true;
         return true;
         return true;
     case WM_MBUTTONUP:
     case WM_MBUTTONUP:
+        ReleaseCapture();
         io.MouseDown[2] = false;
         io.MouseDown[2] = false;
         return true;
         return true;
     case WM_MOUSEWHEEL:
     case WM_MOUSEWHEEL: