Skip to content

MenuItem close parent popups, making stacked popups difficult to use #2200

@ghost

Description

Version/Branch of Dear ImGui:

165

Back-end file/Renderer/OS: (or specify if you are using a custom engine back-end)

Back-ends: imgui_impl_win32cpp + imgui_impl_opengl3.cpp
OS: win10
Compiler: XXX (if the question is related to building)
visual studio 2017
My Issue/Question: (please provide context)
I have a BeginPopupContextItem and inside have 3 MenuItem, which duplicate , rename and delete
my rename will call BeginPopupModal with OpenPopup. however my BeginPopupModal, don't show up.

for below code i remove for tandalone, minimal, complete and verifiable example.
which MenuItem contain only rename and just wnat to pop up the BeginPopupModal.
Standalone, minimal, complete and verifiable example: (see CONTRIBUTING.md)

if (ImGui::BeginPopupContextItem("BeginPopupContextItem"))
{
	ImGui::PushItemWidth(-1);
	if (ImGui::MenuItem("Rename"))
	{
		ImGui::OpenPopup("OpenPopup");
	}
ImGui::PopItemWidth();
	if (ImGui::BeginPopupModal("OpenPopup"))
	{
		static char buf2[64] = "";
		ImGuiInputTextFlags text_flag1 = ImGuiInputTextFlags_None;
		ImGui::PushItemWidth(100);
		ImGui::Text("New Name:");
ImGui::SameLine();

ImGui::InputText("##EditorContentBrowser", buf2, 64, text_flag1, NULL, NULL);
		ImGui::PopItemWidth();
		Std::string new_name = buf2;
		ImGui::Separator();
		if (ImGui::Button("Apply", ImVec2(120, 0))) 
		{ 
			ImGui::CloseCurrentPopup(); 
		}
		ImGui::SetItemDefaultFocus();
		ImGui::SameLine();
		if (ImGui::Button("Cancel", ImVec2(120, 0))) 
		{ 					
			ImGui::CloseCurrentPopup(); 
		}
		ImGui::EndPopup();
	}
							
}

Screenshots/Video (you can drag files here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions