|
@@ -5269,7 +5269,7 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
// - OpenOnDoubleClick .............. double-click anywhere to open
|
|
|
// - OpenOnArrow .................... single-click on arrow to open
|
|
|
// - OpenOnDoubleClick|OpenOnArrow .. single-click on arrow or double-click anywhere to open
|
|
|
- ImGuiButtonFlags button_flags = ImGuiButtonFlags_NoKeyModifiers;
|
|
|
+ ImGuiButtonFlags button_flags = 0;
|
|
|
if (flags & ImGuiTreeNodeFlags_AllowItemOverlap)
|
|
|
button_flags |= ImGuiButtonFlags_AllowItemOverlap;
|
|
|
if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
|
|
@@ -5277,6 +5277,15 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
if (!is_leaf)
|
|
|
button_flags |= ImGuiButtonFlags_PressedOnDragDropHold;
|
|
|
|
|
|
+ // We allow clicking on the arrow section with keyboard modifiers held, in order to easily
|
|
|
+ // allow browsing a tree while preserving selection with code implementing multi-selection patterns.
|
|
|
+ // When clicking on the rest of the tree node we always disallow keyboard modifiers.
|
|
|
+ const float hit_padding_x = style.TouchExtraPadding.x;
|
|
|
+ const float arrow_hit_x1 = (text_pos.x - text_offset_x) - hit_padding_x;
|
|
|
+ const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + hit_padding_x;
|
|
|
+ if (window != g.HoveredWindow || !(g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2))
|
|
|
+ button_flags |= ImGuiButtonFlags_NoKeyModifiers;
|
|
|
+
|
|
|
bool selected = (flags & ImGuiTreeNodeFlags_Selected) != 0;
|
|
|
const bool was_selected = selected;
|
|
|
|
|
@@ -5287,13 +5296,10 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
|
|
{
|
|
|
if (pressed)
|
|
|
{
|
|
|
- const float hit_padding_x = style.TouchExtraPadding.x;
|
|
|
- const float arrow_hit_x1 = (text_pos.x - text_offset_x) - hit_padding_x;
|
|
|
- const float arrow_hit_x2 = (text_pos.x - text_offset_x) + (g.FontSize + padding.x * 2.0f) + hit_padding_x;
|
|
|
- if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
|
|
|
- toggled |= (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2) && (!g.NavDisableMouseHover); // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job
|
|
|
if ((flags & (ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick)) == 0 || (g.NavActivateId == id))
|
|
|
toggled = true;
|
|
|
+ if (flags & ImGuiTreeNodeFlags_OpenOnArrow)
|
|
|
+ toggled |= (g.IO.MousePos.x >= arrow_hit_x1 && g.IO.MousePos.x < arrow_hit_x2) && (!g.NavDisableMouseHover); // Lightweight equivalent of IsMouseHoveringRect() since ButtonBehavior() already did the job
|
|
|
if ((flags & ImGuiTreeNodeFlags_OpenOnDoubleClick) && g.IO.MouseDoubleClicked[0])
|
|
|
toggled = true;
|
|
|
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.
|