You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Opening a popup when clicking in a window will not trigger IsItemDeactivated on a widget that was active in another window.
The same thing happens when calling SetWindowFocus instead of opening a popup.
Interesting to note is, that this only happens when checking for IsMouseClicked(ImGuiMouseButton_Right) but NOT for ImGuiMouseButton_Left.
{ //Note the comment at the bottom about window orderImGui::Begin("Main");
staticint cnt = 0;
ImGui::Text("Deactivated count: %d", cnt);
//Always make this textbox active before clicking into one of the test windows below.//When clicking the windows, the textbox becomes inactive and 'Deactivated count' should increment.//For the two 'BAD' windows, the textbox becomes inactive but the count does not incrementstaticchar buf[256] = { 0 };
ImGui::InputText("MyText", buf, sizeof(buf));
if (ImGui::IsItemDeactivated()) {
cnt++;
}
ImGui::End();
}
bool openPopup = false;
ImGui::Begin("Left_Popup_OK"); //OKif (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left))
openPopup = true;
ImGui::End();
ImGui::Begin("Left_Focus_OK"); //OKif (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Left))
ImGui::SetWindowFocus();
ImGui::End();
ImGui::Begin("Right_Popup_BAD"); //BADif (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right))
openPopup = true;
ImGui::End();
ImGui::Begin("Right_Focus_BAD"); //BADif (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(ImGuiMouseButton_Right))
ImGui::SetWindowFocus();
ImGui::End();
//Open/Begin popup here or directly inside the windows, makes no differenceif (openPopup)
ImGui::OpenPopup("MyPopup");
if (ImGui::BeginPopup("MyPopup")) {
ImGui::Text("Popup");
ImGui::EndPopup();
}
//Moving the code for window 'Main' down here resolves the issue.//Not always an option or hard to keep track of and ensure in complex applications
What's curious to me is the fact that it seems like ImGui does indeed handle windows stealing focus correctly, just not on 'right' mouse clicks. But why would the mouse button matter?
Also note that this only happens when the test window's code comes AFTER the window the contains the widget in question.
Reordering the windows is not always an option and one could easily imagine a scenario where two windows both contain IsItemDeactivated widgets as well as context menus.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered:
Version/Branch of Dear ImGui:
Version 1.90.6 (19052), Branch: docking (master/docking/etc.)
Back-ends:
imgui_impl_win32.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Visual Studio 2022 MSVC C++ 20
Full config/build information:
Details:
Opening a popup when clicking in a window will not trigger
IsItemDeactivated
on a widget that was active in another window.The same thing happens when calling
SetWindowFocus
instead of opening a popup.Interesting to note is, that this only happens when checking for
IsMouseClicked(ImGuiMouseButton_Right)
but NOT forImGuiMouseButton_Left
.What's curious to me is the fact that it seems like ImGui does indeed handle windows stealing focus correctly, just not on 'right' mouse clicks. But why would the mouse button matter?
Also note that this only happens when the test window's code comes AFTER the window the contains the widget in question.
Reordering the windows is not always an option and one could easily imagine a scenario where two windows both contain
IsItemDeactivated
widgets as well as context menus.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: