imgui
imgui copied to clipboard
At times cannot interact with imgui window, WantCaptureMouse stuck as true. Docking, directx12
When using imgui docking (Feb 26th) with my own DX12 code if I do the following:
- move an imgui window off of my DX12 window
- let go of it
- move the window back over my DX12 window
- let go of it
The imgui window becomes often becomes unresponsive and the following bullet points below get stuck returning or set as true.
- ImGui::IsWindowHovered()
- ImGui::IsWindowFocused()
- WantCaptureMouse
I cannot reproduce this error with the imgui dx12 docking branch example code. So I am pretty sure this is being caused by something I did, and I am hoping someone else has made the same mistake and knows what it is.
I have been searching for the issue for some time in my code and google with no success. I have a feeling I missed something as this is my first time using imgui.
My addition of imgui to my code looks like this. There could be mistakes. The variable imgui_io is defined in the class that all of the code runs in.
// Reset command allocator
// Setup calls prior to rendering a scene
// DrawRenderItems
if (useImGui) {
// Start the Dear ImGui frame
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
ImGui::Begin("Hello, world!");
ImGui::TextWrapped("Warning: Moving the this from off the render window to on it can cause it to fail");
// These are all saved as class variables for monitoring them
ImGui_IsWindowHovered = ImGui::IsWindowHovered();
ImGui_IsWindowFocused = ImGui::IsWindowFocused();
ImGui_IsItemActive = ImGui::IsItemActive();
ImGui_WantCaptureMouse = imgui_io->WantCaptureMouse;
ImGui::End();
// Rendering
ImGui::Render();
ImGui_ImplDX12_RenderDrawData(ImGui::GetDrawData(), mCommandList.Get());
}
// ResourceBarrier
mCommandList->Close();
ID3D12CommandList* cmdsLists[] = { mCommandList.Get() };
mCommandQueue->ExecuteCommandLists(_countof(cmdsLists), cmdsLists);
if (useImGui && (imgui_io->ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
{
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault(NULL, (void*)mCommandList.Get());
}
mSwapChain->Present(0, 0);
// Setting signal and fence for later sync
My imgui init code was copied from the dx12 example, aside from the return value from ImGui::GetIO() being saved as a pointer. Thank you.
Leave "Demo>Mouse Inputs" and "Metrics>Internals" open so you can better see what's going on.
Thank you, I did not know about those. I will continue to investigate but I thought I would post an update. Also, posting these seems to help me think through it. The issue may be related to handling user input in two different ways together.
Sorry if putting comments in an image is not normal, it seemed to be a clear way to point at things.
Other details: I have been using GetAsyncKeyState (winuser.h) for keyboard input. Also, using SetCapture(HWND hWnd); and ReleaseCapture(); on mouse down and mouse up.
I also noticed when the imgui windows are over my dx12 window there are rendering artifacts with vsync on or off. When the imgui windows are not over the dx12 window they are okay. Maybe unrelated but just in case I am sharing that detail.
I have been using GetAsyncKeyState (winuser.h) for keyboard input. Also, using SetCapture(HWND hWnd); and ReleaseCapture(); on mouse down and mouse up.
This is confusing, are you actually using win32 + dx12 backend or custom backends?
If things work in the stock example I don't think I have the resources/energy to debug your app. Let us know if you find your issue.
Yes, I am using the win32 + dx12 backend for imgui. (not the rest of the dx12 app) No problem. I was mostly hoping that someone had come across this in the past and could easily comment.
From your response, it seems like the issue is more likely something caused by the code set that I am using. I will post if I figure out what is causing the issue.
@Eths33 I'm having the same issue, did you fixed it?
Same issue but it's random. Usually happens when I leave the app and then return to the app and all ImGui windows are then unusable. Double click would still let me select it but that's a useless action on its own. By going crazy with alt-tab and stuff it sometimes randomly "comes back" (works again). The problem is once I start debugging and then try to understand the input events and then return into the app ImGui is working again. That + it's completely random to occur makes it so annoying to try to fix because I have to stop what I was actually working on in the moment and then try to debug but then debugging itself makes it work again so I stopped what I was doing for no reason.
Edit: actually I should note that I'm still on an old ImGui codebase. I'll upgrade first and I'll come back about whether it happens with the latest ImGui too.
Same issue but it's random. Usually happens when I leave the app and then return to the app and all ImGui windows are then unusable. Double click would still let me select it but that's a useless action on its own. By going crazy with alt-tab and stuff it sometimes randomly "comes back" (works again). The problem is once I start debugging and then try to understand the input events and then return into the app ImGui is working again. That + it's completely random to occur makes it so annoying to try to fix because I have to stop what I was actually working on in the moment and then try to debug but then debugging itself makes it work again so I stopped what I was doing for no reason.
Edit: actually I should note that I'm still on an old ImGui codebase. I'll upgrade first and I'll come back about whether it happens with the latest ImGui too.
which imgui version was you using? i was using v1.86 and i upgraded to 1.88, it seems fixed, but i didn't have enough time for testing
It's still happening on v1.88 for me. On Windows btw (so Winapi). It comes back after clicking on other apps and alt-tabbing randomly and unreliably (inconsistent)
It's still happening on v1.88 for me. On Windows btw (so Winapi). It comes back after clicking on other apps and alt-tabbing randomly and unreliably (inconsistent)
Yeah, if u find a fix, please let me know
Having the same issue, using directx9 and winapi
One of you would need to take the time to investigate, provide more details and hopefully a repro, because at that point all I can read are incomplete details.
Start from our example app and compare your code to it, or make modifications on one side or the other to make them closer.
Not sure if related since I'm actually using ImGui in the context of Unreal Engine, however, I had the same/similar issue when disabling ImGuiInput during ImGui::IsMouseClicked. After enabling the input again the ImGui windows were unresponsive and could not be selected. Now I'm using ImGui::IsMouseReleased to disable input I don't get any issues after I turn input back on. Hope that helps.