mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
TreeNode: Made clicking on arrow toggle toggle the open state on the Mouse Down event. Amend 05420ea2c
.
This commit is contained in:
@ -5644,17 +5644,14 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
|
||||
|
||||
// Open behaviors can be altered with the _OpenOnArrow and _OnOnDoubleClick flags.
|
||||
// Some alteration have subtle effects (e.g. toggle on MouseUp vs MouseDown events) due to requirements for multi-selection and drag and drop support.
|
||||
// - Single-click on label = Toggle on MouseUp (default)
|
||||
// - Single-click on arrow = Toggle on MouseUp (when _OpenOnArrow=0)
|
||||
// - Single-click on label = Toggle on MouseUp (default, when _OpenOnArrow=0)
|
||||
// - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=0)
|
||||
// - Single-click on arrow = Toggle on MouseDown (when _OpenOnArrow=1)
|
||||
// - Double-click on label = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1)
|
||||
// - Double-click on arrow = Toggle on MouseDoubleClick (when _OpenOnDoubleClick=1 and _OpenOnArrow=0)
|
||||
// This makes _OpenOnArrow have a subtle effect on _OpenOnDoubleClick: arrow click reacts on Down rather than Up.
|
||||
// It is rather standard that arrow click react on Down rather than Up and we'd be tempted to make it the default
|
||||
// (by removing the _OpenOnArrow test below), however this would have a perhaps surprising effect on CollapsingHeader()?
|
||||
// So right now we are making this optional. May evolve later.
|
||||
// It is rather standard that arrow click react on Down rather than Up.
|
||||
// We set ImGuiButtonFlags_PressedOnClickRelease on OpenOnDoubleClick because we want the item to be active on the initial MouseDown in order for drag and drop to work.
|
||||
if (is_mouse_x_over_arrow && (flags & ImGuiTreeNodeFlags_OpenOnArrow))
|
||||
if (is_mouse_x_over_arrow)
|
||||
button_flags |= ImGuiButtonFlags_PressedOnClick;
|
||||
else if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
|
||||
button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick;
|
||||
|
Reference in New Issue
Block a user