From e0da1e06584869c150f3d82084b3d36e9cd51dce Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 2 Jul 2015 09:20:15 -0600 Subject: [PATCH] Split into CaptureKeyboardFromApp() / CaptureMouseFromApp() --- imgui.cpp | 12 ++++++++---- imgui.h | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 59992268c..4645d2b34 100644 --- a/imgui.cpp +++ b/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(); } diff --git a/imgui.h b/imgui.h index 52255db0a..4e12ba473 100644 --- a/imgui.h +++ b/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);