-
-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Suggestion: do not focus window when the close button is clicked #8683
Copy link
Copy link
Closed
Description
Version/Branch of Dear ImGui:
Version 1.91.9
Back-ends:
Any
Compiler, OS:
Any
Full config/build information:
No response
Details:
When users close a window by clicking the close button, if the window is hidden by other windows, it will be brought to the foreground (due to focus) and disappear immediately (due to close), which is not ideal.
Screenshots/Video:
Current behavior (note that Window C will be brought to foreground for one frame due to focus):

Expected behavior (Window C will disappear directly):

The expected behavior can be achieved by adding extra modes to ButtonBehavior (without focusing the window).
See ec6fb8d.
Minimal, Complete and Verifiable Example code:
bool close_button_no_focus = false;
static void example() {
static bool b = true, c = true;
const ImGuiWindowFlags flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoSavedSettings;
if (ImGui::Begin("Window A", 0, flags)) {
ImGui::Checkbox("Close button: don't focus window", &close_button_no_focus);
ImGui::Checkbox("Window B", &b);
ImGui::Checkbox("Window C", &c);
}
ImGui::End();
if (b) {
ImGui::Begin("Window B", &b, flags);
ImGui::Text("--- Window B ---");
ImGui::End();
}
if (c) {
ImGui::Begin("Window C", &c, flags);
ImGui::Text("--- Window C ---");
ImGui::End();
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels