Skip to content

Commit

Permalink
Popups: clarified meaning of 'p_open != NULL' in BeginPopupModal() + …
Browse files Browse the repository at this point in the history
…set back user value to false when popup is closed in ways other than clicking the close button. (#6900)
  • Loading branch information
ocornut committed Oct 5, 2023
1 parent 2c07d58 commit 1107bff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ Other changes:
- Mostly legacy behavior when used inside old Columns(), as we favored that idiom back then,
only different is left position follows indentation level, to match calling a Separator()
inside or outside Columns().
- Popups: clarified meaning of 'p_open != NULL' in BeginPopupModal() + set back user value
to false when popup is closed in ways other than clicking the close button. (#6900)
- Drag and Drop: Rework drop target highlight: reduce rectangle to its visible portion, and
then expand slightly. A full rectangle is always visible and it may protrude slightly. (#4281, #3272)
- Drag and Drop: Fixed submitting a tooltip from drop target location when using AcceptDragDropPayload()
Expand Down
6 changes: 5 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10577,7 +10577,9 @@ bool ImGui::BeginPopup(const char* str_id, ImGuiWindowFlags flags)
}

// If 'p_open' is specified for a modal popup window, the popup will have a regular close button which will close the popup.
// Note 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.
// Note that popup visibility status is owned by Dear ImGui (and manipulated with e.g. OpenPopup).
// - *p_open set back to false in BeginPopupModal() when popup is not open.
// - if you set *p_open to false before calling BeginPopupModal(), it will close the popup.
bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags flags)
{
ImGuiContext& g = *GImGui;
Expand All @@ -10586,6 +10588,8 @@ bool ImGui::BeginPopupModal(const char* name, bool* p_open, ImGuiWindowFlags fla
if (!IsPopupOpen(id, ImGuiPopupFlags_None))
{
g.NextWindowData.ClearFlags(); // We behave like Begin() and need to consume those values
if (p_open && *p_open)
*p_open = false;
return false;
}

Expand Down

0 comments on commit 1107bff

Please sign in to comment.