-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't open a normal or modal popup inside a MenuBar + Menu inside it #5684
Comments
The issue is that you're submitting the popup within the scope of the if statement for Unfortunately this isn't as simple as moving your You can either use the |
Thank you a lot for the reply. Got it working. So, now I know to handle the popups outside the Solution for others to look: if (ImGui::BeginMenuBar()) {
if (ImGui::BeginMenu("Settings")) {
if (ImGui::MenuItem("KahviBreak directory")) {
popups.kahvi_dir_popup = true;
}
if (ImGui::BeginMenu("Theme")) {
if (ImGui::MenuItem("Dark")) {
ImGui::StyleColorsDark();
}
if (ImGui::MenuItem("Light")) {
ImGui::StyleColorsLight();
}
ImGui::EndMenu();
}
ImGui::EndMenu();
}
if (ImGui::MenuItem("About")) {
popups.about_popup = true;
}
if (ImGui::MenuItem("Exit")) {
glfwSetWindowShouldClose(win, true);
}
ImGui::EndMenuBar();
}
ImGui::End();
if (popups.about_popup) {
ImGui::OpenPopup("About");
}
components::about_popup_handle();
if (popups.kahvi_dir_popup) {
ImGui::OpenPopup("KahviBreak directory");
}
components::directory_modal_handle();
ImGui::ShowDemoWindow(); I modified the components blocks this way: inline void about_popup_handle() {
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x / 2, ImGui::GetIO().DisplaySize.y / 2),
ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopup("About", ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("drinkKahvi");
ImGui::Separator();
ImGui::Text("A simple KahviBreak entry exporter to .zip for curations");
ImGui::Text("Made by: memoryhunter");
ImGui::EndPopup();
}
}
inline void directory_modal_handle() {
ImGui::SetNextWindowPos(ImVec2(ImGui::GetIO().DisplaySize.x / 2, ImGui::GetIO().DisplaySize.y / 2),
ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
if (ImGui::BeginPopup("KahviBreak directory", ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::Text("KahviBreak directory");
ImGui::Separator();
ImGui::Text("Please select the KahviBreak directory:");
std::string directory{};
ImGui::InputText("###KahviBreak directory", &directory);
ImGui::EndPopup();
}
} Just a slight change, to have every boolean named for each popup, instead of array, I created a struct with booleans named accordingly. |
Version/Branch of Dear ImGui:
Version: 1.88
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: cl.exe
Operating System: Windows 10
My Issue/Question:
I am having an issue when trying to make a modal popup inside a Menu bar and a Menu inside it.
I had trouble making a normal popup straight away in the Menu bar, but #331 was of help, so that's fine.
I utilized the same way of making the popup but inside a Menu this time, doesn't seem to work.
Screenshots/Video
Standalone, minimal, complete and verifiable example:
I have taken out the popup code in an outside header in
inline
blocks of functionThe text was updated successfully, but these errors were encountered: