Split into CaptureKeyboardFromApp() / CaptureMouseFromApp()

This commit is contained in:
ocornut 2015-07-02 09:20:15 -06:00
parent 77fad80e9f
commit e0da1e0658
2 changed files with 10 additions and 5 deletions

View File

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

View File

@ -385,7 +385,8 @@ namespace ImGui
IMGUI_API void ResetMouseDragDelta(int button = 0); // 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 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 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() // Helpers functions to access the MemAllocFn/MemFreeFn pointers in ImGui::GetIO()
IMGUI_API void* MemAlloc(size_t sz); IMGUI_API void* MemAlloc(size_t sz);