imgui_sdl icon indicating copy to clipboard operation
imgui_sdl copied to clipboard

Input from imgui in example.cpp doesn't work

Open Mtkn573 opened this issue 4 years ago • 1 comments

Input doesn't handle events properly. I used code from example.cpp.

Mtkn573 avatar May 07 '21 13:05 Mtkn573

The simplest way to get inputs to work reliably is to use the built-in backend (https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_sdl.cpp). Now the problem is the generic ImGui_ImplSDL2_Init is not public - only ImGui_ImplSDL2_InitForOpenGL etc. But at least as of now, these do not do anything really, just forward to ImGui_ImplSDL2_Init. So, to get inputs, resize events etc. working, that's all you need:

ImGui_ImplSDL2_InitForOpenGL(window, nullptr);
(...)
SDL_Event event;
while (SDL_PollEvent(&event)) ImGui_ImplSDL2_ProcessEvent(&event);
(...)
ImGui_ImplSDL2_NewFrame(window);
ImGui::NewFrame();

gwiazdorrr avatar Sep 07 '21 14:09 gwiazdorrr