ImGuiNET / ImGui.NET

An ImGui wrapper for .NET.
MIT License
1.87k stars 305 forks source link

Popups #461

Open MetalDeveloper opened 8 months ago

MetalDeveloper commented 8 months ago

is their an example of popups that I could look at?

NoahStolk commented 8 months ago

Do you mean something like this?

if (ImGui.Begin("Main Window", ImGuiWindowFlags.NoCollapse))
{
    if (ImGui.BeginPopup("PopupName"))
    {
        ImGui.Text("Test popup");

        if (ImGui.Button("Close popup"))
            ImGui.CloseCurrentPopup();

        ImGui.EndPopup();
    }

    if (ImGui.Button("Open popup"))
        ImGui.OpenPopup("PopupName");
}

ImGui.End();

I recommend using imgui_demo.cpp as a reference: https://github.com/ocornut/imgui/blob/master/imgui_demo.cpp

The ImGui demo is really good and showcases almost everything you need. Whenever I'm not sure how to do something, I open the demo in C# by calling ImGui.ShowDemoWindow();, find whatever I need, and then look at how it's done in imgui_demo.cpp.