Inconsistency between p_open Functionality and Documentation in BeginPopupModal #6900

Closed
opened 2023-10-05 15:19:07 +00:00 by sakiodre · 0 comments
sakiodre commented 2023-10-05 15:19:07 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version: 1.89.9 WIP
Branch: master

My Issue/Question:

The comment for BeginPopupModal, added in commit #f1c75964, mentions that:

popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here.

However, when p_open is set to false when passed to the function, this condition evaluates to false, which returns false and hides the popup. Tracing back through the git history, this if block dates back to #8c790a32 when p_open was first added.

The code clearly indicates that if p_open is false, the popup will not be displayed, contradicting the comment. Could you clarify the intended behavior?

Standalone, minimal, complete and verifiable example:

ImGui::Begin("window");

if (ImGui::Button("open"))
    ImGui::OpenPopup("popup window");

bool p_open = false;

if (ImGui::BeginPopupModal("popup window", &p_open))
{
    ImGui::EndPopup();
}

ImGui::End();
**Version/Branch of Dear ImGui:** Version: 1.89.9 WIP Branch: master **My Issue/Question:** The comment for `BeginPopupModal`, added in commit [`#f1c75964`](https://github.com/ocornut/imgui/commit/f1c75964#diff-cee9beb740469eb5192dfe94aaee7320932590adade9d9b1d2ee392ac2e1e88cR6611), mentions that: > popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup) so the actual value of *p_open is meaningless here. However, when `p_open` is set to false when passed to the function, [this condition](https://github.com/ocornut/imgui/blob/2c07d581de7396753ea873fb765ffc7d411fecad/imgui.cpp#L10603) evaluates to false, which returns false and hides the popup. Tracing back through the git history, this if block dates back to [`#8c790a32`](https://github.com/ocornut/imgui/commit/8c790a32#diff-cee9beb740469eb5192dfe94aaee7320932590adade9d9b1d2ee392ac2e1e88cR3250) when `p_open` was first added. The code clearly indicates that if `p_open` is false, the popup will not be displayed, contradicting the comment. Could you clarify the intended behavior? **Standalone, minimal, complete and verifiable example:** ```cpp ImGui::Begin("window"); if (ImGui::Button("open")) ImGui::OpenPopup("popup window"); bool p_open = false; if (ImGui::BeginPopupModal("popup window", &p_open)) { ImGui::EndPopup(); } ImGui::End(); ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#6900
No description provided.