jvcleave / ofxImGui

Use ImGui in openFrameworks
300 stars 123 forks source link

Closing a window within a window? #117

Closed BrianBeuken closed 1 year ago

BrianBeuken commented 1 year ago

Sorry, this should be clear and I see some people have made suggestions, but don't want to disable the actual |>name tag, so the window can be re-opened or expanded when wanted, I just want to close/fold the window that was opened, but from within the window. I can't seem to find a way to do that?

Daandelange commented 1 year ago

Hello, I don't understand the "disable" part of your question, but controlling the "collapsed state" of a window is definitely possible :

static bool bShowWindow = true;
// ImGui::SetNextWindowCollapsed(true, ImGuiCond_Always); // Before opening the window
if(ImGui::Begin("MyWindow", &bShowWindow)){
    if(ImGui::Button("HIT ME !")){
        ImGui::SetWindowCollapsed(true, ImGuiCond_Always); // Within the same window
    }
}
ImGui::End();
BrianBeuken commented 1 year ago

Thanks that looks like the missing piece, I'll let you know.

Daandelange commented 1 year ago

Closing, feel free to re-open to post feedback.