Skip to content

Commit c801799

Browse files
committed
Added an assertion for the common user mistake of using "" as an identifier at the root level of a window. (#1414, #2562, #2807, #4008, #4158, #4375, #4548, #4657, #4796)
#4158, #4375, #4548, #4657, #4796)
1 parent a8e1dde commit c801799

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

docs/CHANGELOG.txt

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ Breaking Changes:
4141

4242
Other Changes:
4343

44+
- Added an assertion for the common user mistake of using "" as an identifier at the root level of a window
45+
instead of using "##something". Empty identifiers are valid and useful in a very small amount of cases,
46+
but 99.9% of the time if you need an empty label you should use "##something". (#1414, #2562, #2807, #4008,
47+
#4158, #4375, #4548, #4657, #4796). READ THE FAQ ABOUT HOW THE ID STACK WORKS -> https://dearimgui.org/faq
4448
- Added GetMouseClickedCount() function, returning the number of successive clicks. (#3229) [@kudaba]
4549
(so IsMouseDoubleClicked(ImGuiMouseButton_Left) is same as GetMouseClickedCount(ImGuiMouseButton_Left) == 2,
4650
but it allows testing for triple clicks and more).

imgui.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -7760,6 +7760,11 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
77607760
if (window == g.NavWindow || ((window->Flags | g.NavWindow->Flags) & ImGuiWindowFlags_NavFlattened))
77617761
NavProcessItem();
77627762

7763+
// [DEBUG] People keep stumbling on this problem and using "" as identifier in the root of a window instead of "##something".
7764+
// Empty identifier are valid and useful in a small amount of cases, but 99.9% of the time you want to use "##something".
7765+
// READ THE FAQ: https://dearimgui.org/faq
7766+
IM_ASSERT(id != window->ID && "Cannot have an empty ID at the root of a window. If you need an empty label, use ## and read the FAQ about how the ID Stack works!");
7767+
77637768
// [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd()
77647769
#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
77657770
if (id == g.DebugItemPickerBreakId)

0 commit comments

Comments
 (0)