1

How I can destroy imgui window by clicking X

void test::OnUIRender()
{
    bool state;
    ImGui::Begin("test_test", &state);
    if (ImGui::Button("test")) 
    {
        ImGui::DestroyContext();
    }
    ImGui::End();
}

screenshot

drescherjm
  • 10,365
  • 5
  • 44
  • 64
Msen
  • 11
  • 2
  • Check `state` . – tkausl Jul 25 '22 at 20:46
  • What function I can use for destroy imgui window without touching main window – Msen Jul 25 '22 at 20:51
  • Your `state` variable is: - Not initialized - Not preserved across frames, therefore reset every time. - Not tested by your code e.g. `if (state) { ImGui::Begin(...)` as it should. – Omar Mar 23 '23 at 18:29

0 Answers0