diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 4867abea..51fbb663 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -44,6 +44,7 @@ Breaking Changes: Other Changes: - Nav: To keep the navigated item in view we also attempt to scroll the parent window as well as the current window. (#787) + - TreeNode: Fixed nodes with ImGuiTreeNodeFlags_Leaf flag always returning true which was meaningless. ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index 21cbd245..8ab867d2 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -8109,7 +8109,7 @@ void ImGui::LogButtons() bool ImGui::TreeNodeBehaviorIsOpen(ImGuiID id, ImGuiTreeNodeFlags flags) { if (flags & ImGuiTreeNodeFlags_Leaf) - return true; + return false; // We only write to the tree storage if the user clicks (or explicitly use SetNextTreeNode*** functions) ImGuiContext& g = *GImGui; diff --git a/imgui_demo.cpp b/imgui_demo.cpp index da6a5c86..2f458f7c 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -457,9 +457,9 @@ void ImGui::ShowDemoWindow(bool* p_open) else { // Leaf: The only reason we have a TreeNode at all is to allow selection of the leaf. Otherwise we can use BulletText() or TreeAdvanceToLabelPos()+Text(). - node_flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen; // ImGuiTreeNodeFlags_Bullet + node_flags |= ImGuiTreeNodeFlags_Leaf; // | ImGuiTreeNodeFlags_Bullet; ImGui::TreeNodeEx((void*)(intptr_t)i, node_flags, "Selectable Leaf %d", i); - if (ImGui::IsItemClicked()) + if (ImGui::IsItemClicked()) node_clicked = i; } } @@ -3188,13 +3188,9 @@ static void ShowExampleAppPropertyEditor(bool* p_open) } else { + // Here we use a TreeNode to highlight on hover (we could use e.g. Selectable as well) ImGui::AlignTextToFramePadding(); - // Here we use a Selectable (instead of Text) to highlight on hover - //ImGui::Text("Field_%d", i); - char label[32]; - sprintf(label, "Field_%d", i); - ImGui::Bullet(); - ImGui::Selectable(label); + ImGui::TreeNodeEx("Field", ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_Bullet, "Field_%d", i); ImGui::NextColumn(); ImGui::PushItemWidth(-1); if (i >= 5)