Skip to content

Commit

Permalink
Split into CaptureKeyboardFromApp() / CaptureMouseFromApp()
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Jul 2, 2015
1 parent 77fad80 commit e0da1e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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();
}
Expand Down
3 changes: 2 additions & 1 deletion imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e0da1e0

Please sign in to comment.