Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree node single click / double click expand behavior inconsistency #2099

Closed
sherief opened this issue Sep 25, 2018 · 3 comments
Closed

Tree node single click / double click expand behavior inconsistency #2099

sherief opened this issue Sep 25, 2018 · 3 comments
Labels
inputs tree tree nodes

Comments

@sherief
Copy link

sherief commented Sep 25, 2018

Version/Branch of Dear ImGui: 1.66 WIP

Back-end file/Renderer/OS: Custom engine backend (D3D12 / Win32)

My Issue/Question:

Tree nodes created without the ImGuiTreeNodeFlags_OpenOnDoubleClick flag have the following behavior: they receive a mouse down, then a mouse up, and after the mouse up they expand.

Tree nodes created with the ImGuiTreeNodeFlags_OpenOnDoubleClick flag have a slightly off behavior: they receive a mouse down, mouse up, second mouse down, then then expand, then a second mouse up.

For consistency (both with imgui and most OSes), tree nodes set to open with a double click should open on the mouse up of the second click event.

Standalone, minimal, complete and verifiable example:

ImGui::Begin("Trees");
{
const ImGuiTreeNodeFlags NodeFlags = 0;
const bool NodeOpen = ImGui::TreeNodeEx(this, NodeFlags, "Click me!");
if(NodeOpen) ImGui::TreePop();
}
{
const ImGuiTreeNodeFlags NodeFlags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ((this == SelectedObject) ? ImGuiTreeNodeFlags_Selected : 0);
const bool NodeOpen = ImGui::TreeNodeEx(this, NodeFlags, "Double click me!");
if(NodeOpen) ImGui::TreePop();
}
ImGui::End();
@ocornut ocornut added tree tree nodes inputs labels Sep 25, 2018
@ocornut
Copy link
Owner

ocornut commented Sep 25, 2018

For consistency (both with imgui and most OSes), tree nodes set to open with a double click should open on the mouse up of the second click event.

In Windows Explorer, double-click actions seems to be triggered on the mouse-down event.
In text editors all across my Windows machine, word selection with double-click are also triggered on the mouse-down event.

Could you clarify:

  • Your references for handling the typical double-click action on mouse-up.
  • Your use case where it does matter?

I do have one:
When working on multi-selection patterns (#1861, I have a branch for it) I noticed that for various subtle reasons, some reactions differ whether the CTRL key is held. Indeed, in Explorer double-click without CTRL held is triggered on mouse-down, whereas double-click with CTRL held is triggered on mouse-up. This seems to be mimicking the behavior of selection-on-simple-click, which also differ in a similar way to allow drag and dropping a group without resetting the selection when CTRL is not held.

TL;DR; Not as simple, need more details.

@sherief
Copy link
Author

sherief commented Oct 4, 2018

Would a simple "Sorry, I'll do my homework next time before I embarrass myself" be considered an acceptable apology? :D

@sherief sherief closed this as completed Oct 4, 2018
@ocornut
Copy link
Owner

ocornut commented Oct 5, 2018

No need to apologize! I am more than happy to close issues rather than have them grow into tricky problems :) I suspect you had something specific in mind and you'll stumble on it again later, when that happen you may have more details.

Not directly related, but at the moment (even with my experiment multi-select api) it is probably not trivial to to create something as full-featured as Explorer (multi-selection, drag and drop, renaming, etc.). It is one target to demonstrate it and make any needed improvement/changes to the Tree API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inputs tree tree nodes
Projects
None yet
Development

No branches or pull requests

2 participants