Răsfoiți Sursa

Split into CaptureKeyboardFromApp() / CaptureMouseFromApp()

ocornut 10 ani în urmă
părinte
comite
e0da1e0658
2 a modificat fișierele cu 10 adăugiri și 5 ștergeri
  1. 8 4
      imgui.cpp
  2. 2 1
      imgui.h

+ 8 - 4
imgui.cpp

@@ -3007,10 +3007,14 @@ void ImGui::SetMouseCursor(ImGuiMouseCursor cursor_type)
     GImGui->MouseCursor = cursor_type;
 }
 
-void ImGui::CaptureInputsFromApp(bool capture_mouse, bool capture_keyboard)
+void ImGui::CaptureKeyboardFromApp()
 {
-    GImGui->CaptureMouseNextFrame |= capture_mouse;
-    GImGui->CaptureKeyboardNextFrame |= capture_keyboard;
+    GImGui->CaptureKeyboardNextFrame = true;
+}
+
+void ImGui::CaptureMouseFromApp()
+{
+    GImGui->CaptureMouseNextFrame = true;
 }
 
 bool ImGui::IsItemHovered()
@@ -11869,7 +11873,7 @@ void ImGui::ShowTestWindow(bool* opened)
 
             ImGui::Button("Hover me\nto enforce\ninputs capture");
             if (ImGui::IsItemHovered())
-                ImGui::CaptureInputsFromApp();
+                ImGui::CaptureKeyboardFromApp();
 
             ImGui::TreePop();
         }

+ 2 - 1
imgui.h

@@ -385,7 +385,8 @@ namespace ImGui
     IMGUI_API void          ResetMouseDragDelta(int button = 0);                                // 
     IMGUI_API ImGuiMouseCursor GetMouseCursor();                                                // get desired cursor type, reset in ImGui::NewFrame(), this updated during the frame. valid before Render(). If you use software rendering by setting io.MouseDrawCursor ImGui will render those for you
     IMGUI_API void          SetMouseCursor(ImGuiMouseCursor type);                              // set desired cursor type
-    IMGUI_API void          CaptureInputsFromApp(bool mouse = true, bool keyboard = true);      // manually enforce imgui setting the io.WantCaptureMouse / io.WantCaptureKeyboard flags next frame (your application needs to handle them). e.g. capture keyboard when your widget is being hovered.
+    IMGUI_API void          CaptureKeyboardFromApp();                                           // manually enforce imgui setting the io.WantCaptureKeyboard flag next frame (your application needs to handle it). e.g. capture keyboard when your widget is being hovered.
+    IMGUI_API void          CaptureMouseFromApp();                                              // manually enforce imgui setting the io.WantCaptureMouse flag next frame (your application needs to handle it).
 
     // Helpers functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO()
     IMGUI_API void*         MemAlloc(size_t sz);