How do I prevent clicking background when I click the IMGUI button (e.g. I click the translate button and also click the background)
Asked
Active
Viewed 2,241 times
1 Answers
2
Check whether ImGui wants to capture the mouse click using ImGui::GetIO().WantCaptureMouse
. If it does then don't let the event propagate further.
void Application::handleInput(InputEvent event) {
// don't pass mouse and keyboard presses further if an ImGui widget is active
auto& io = ImGui::GetIO();
if (io.WantCaptureMouse || io.WantCaptureKeyboard) {
return;
}
// ... event processing
}
}
ImGui FAQ: Q: How can I tell whether to dispatch mouse/keyboard to Dear ImGui or my application?

Jan Šimek
- 656
- 8
- 21