From c234426f8985a30ac6c464f409ca75bedb38f85d Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 19 Feb 2026 16:32:14 +0100 Subject: [PATCH] TreeNode: comments on ImGuiTreeNodeFlags_Leaf. (#4833) --- imgui.h | 2 +- imgui_widgets.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/imgui.h b/imgui.h index 6ab81771f..a68e81010 100644 --- a/imgui.h +++ b/imgui.h @@ -1306,7 +1306,7 @@ enum ImGuiTreeNodeFlags_ ImGuiTreeNodeFlags_DefaultOpen = 1 << 5, // Default node to be open ImGuiTreeNodeFlags_OpenOnDoubleClick = 1 << 6, // Open on double-click instead of simple click (default for multi-select unless any _OpenOnXXX behavior is set explicitly). Both behaviors may be combined. ImGuiTreeNodeFlags_OpenOnArrow = 1 << 7, // Open when clicking on the arrow part (default for multi-select unless any _OpenOnXXX behavior is set explicitly). Both behaviors may be combined. - ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). + ImGuiTreeNodeFlags_Leaf = 1 << 8, // No collapsing, no arrow (use as a convenience for leaf nodes). Note: will always open a tree/id scope and return true. If you never use that scope, add ImGuiTreeNodeFlags_NoTreePushOnOpen. ImGuiTreeNodeFlags_Bullet = 1 << 9, // Display a bullet instead of arrow. IMPORTANT: node can still be marked open/close if you don't set the _Leaf flag! ImGuiTreeNodeFlags_FramePadding = 1 << 10, // Use FramePadding (even for an unframed text node) to vertically align text baseline to regular widget height. Equivalent to calling AlignTextToFramePadding() before the node. ImGuiTreeNodeFlags_SpanAvailWidth = 1 << 11, // Extend hit box to the right-most edge, even if not framed. This is not the default in order to allow adding other items on the same line without using AllowOverlap mode. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e8b819197..928942964 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -6744,6 +6744,7 @@ void ImGui::TreeNodeSetOpen(ImGuiID storage_id, bool is_open) bool ImGui::TreeNodeUpdateNextOpen(ImGuiID storage_id, ImGuiTreeNodeFlags flags) { + // Leaf node always open a new tree/id scope. If you never use it, add ImGuiTreeNodeFlags_NoTreePushOnOpen. if (flags & ImGuiTreeNodeFlags_Leaf) return true;