TreeNode: Fixed bug where BeginDragDropSource() failed when the _OpenOnDoubleClick flag is set. Added basic demo code. (Amend 05420ea)

This commit is contained in:
omar
2020-04-15 12:31:51 +02:00
parent e8c986b34e
commit 54b38d88f7
3 changed files with 26 additions and 1 deletions

View File

@ -5360,10 +5360,11 @@ bool ImGui::TreeNodeBehavior(ImGuiID id, ImGuiTreeNodeFlags flags, const char* l
// 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.
// 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))
button_flags |= ImGuiButtonFlags_PressedOnClick;
else if (flags & ImGuiTreeNodeFlags_OpenOnDoubleClick)
button_flags |= ImGuiButtonFlags_PressedOnDoubleClick;
button_flags |= ImGuiButtonFlags_PressedOnClickRelease | ImGuiButtonFlags_PressedOnDoubleClick;
else
button_flags |= ImGuiButtonFlags_PressedOnClickRelease;