Skip to content

Commit ee3373d

Browse files
committed
TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897)
1 parent ccb2a94 commit ee3373d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Breaking Changes:
3838

3939
Other Changes:
4040
- InputText, Nav: Fixed Home/End key broken when activating Keyboard Navigation. (#787)
41+
- TreeNode: Fixed combination of ImGuiTreeNodeFlags_SpanFullWidth and ImGuiTreeNodeFlags_OpenOnArrow
42+
incorrectly locating the arrow hit position to the left of the frame. (#2451, #2438, #1897)
4143

4244

4345
-----------------------------------------------------------------------

imgui_widgets.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -5270,9 +5270,11 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
52705270
{
52715271
if (pressed)
52725272
{
5273+
const float arrow_x1 = text_pos.x - text_offset_x;
5274+
const float arrow_x2 = arrow_x1 + g.FontSize + padding.x * 2.0f;
52735275
toggled = !(flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) || (g.NavActivateId == id);
52745276
if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
5275-
toggled |= IsMouseHoveringRect(interact_bb.Min, ImVec2(interact_bb.Min.x + text_offset_x, interact_bb.Max.y)) && (!g.NavDisableMouseHover);
5277+
toggled |= IsMouseHoveringRect(ImVec2(arrow_x1, interact_bb.Min.y), ImVec2(arrow_x2, interact_bb.Max.y)) && (!g.NavDisableMouseHover);
52765278
if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
52775279
toggled |= g.IO.MouseDoubleClicked[0];
52785280
if (g.DragDropActive && is_open) // When using Drag and Drop "hold to open" we keep the node highlighted after opening, but never close it again.

0 commit comments

Comments
 (0)