-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Seeking something like "IsAnyOtherItemHovered()" to fix interaction with multiple overlapping elements #3909
Comments
Yes it return true if any item has been hovered in the previous frame.
It's a 1 line function you can check the code. It's hard to understand what you are getting at with your question, I reckon you should be looking at This is going to be confusing as relatively to half-implemented/designed API, but I'm still going to write it down: ImGui::Begin("Overlap");
ImGui::SetCursorPos(ImVec2(50, 50));
bool button_1_pressed = ImGui::Button("11111", ImVec2(50, 50));
bool button_1_hovered = ImGui::IsItemHovered();
//ImGui::SetItemAllowOverlap();
ImGui::SetCursorPos(ImVec2(70, 70));
bool button_2_pressed = ImGui::Button("22222", ImVec2(50, 50));
bool button_2_hovered = ImGui::IsItemHovered();
ImGui::Text("Button 1: %s%s", button_1_hovered ? "hovered " : "", button_1_pressed ? "PRESSED " : "");
ImGui::Text("Button 2: %s%s", button_2_hovered ? "hovered " : "", button_2_pressed ? "PRESSED " : "");
ImGui::End(); When hovering in the intersection of both button: (A) Without SetItemAllowOverlap() after Button 1
(B) With SetItemAllowOverlap() after Button 1
(C) With (internal) ImGuiButtonFlags_AllowItemOverlap flag on Button 1 + SetItemAllowOverlap() after Button 1
Added records of 1.88 behavior on 2023/06:
Notice issues:
Added records of 1.88 behavior on 2023/06:
(This is a a bit of a mess. There are they two aspects: the |
Thank you for this excellent explanation. I guess I have to think about this. Some thoughts, though:
But I'm sure, that you already thought about this problem. If there would be an easy solution, you would have done it already... |
Correct.
This was never advertised much because of the subtleties between case B and C and the potential need for both. However, plot twist discovered via #6512, case B simply doesn't work since 1.89 because of the introduction of the input ownership system. Update of preceding report following changes in 1.89+. When hovering in the intersection of both button, case A and C are identical, but case B changes: (B after 1.89) With SetItemAllowOverlap() after Button 1 but not using ImGuiButtonFlags_AllowItemOverlap in Button 1:
This is because Button 1 takes ownership for I am going to work on a solution for this. |
…AllowtemOverlap in TableUpdateBorders(). (#6512, #3909) This was copied from SplitterBehavior(). The only hypothetical value in SplitterBehavior() would be ability to manually call SetItemAllowOverlap() after the call. Btw generally AllowOverlap is undesirable for columns as e.g. a spanning selectable would cover entire width and prevent columns from being used. # Conflicts: # imgui_tables.cpp
I have pushed a bunch of changes related to AllowOverlap mode. See this comment for details: #6512 (comment) TL;DR;
|
Version/Branch of Dear ImGui:
Version: 1.77
Branch: master
Back-end/Renderer/Compiler/OS
Back-ends: imgui.net
Operating System: win10
My Issue/Question:
I know that overlapping interactive elements are tricky to implement with a single pass immediate UI.
And I learned, that it is possible to partly resolve the inversed draw/interaction sort order by channel splitting.
I normally try to work around or ignore these problems, but for my timeline editing this get kind of annoying.
I am wondering, if there is the possibility to prevent multiple click events by something like this...
For some reason however,
somethingElseWasHovered
becomes true even before the invisible button is being drawn. Obviously I don't understand what's going on (I guess some information from the previous frame must be used for this).IsAnyItemHovered()
works? (search the documentation in imgui.h)Screenshots/Video
https://user-images.githubusercontent.com/1732545/111050991-336d8e00-8450-11eb-8616-c325f622ccdc.mp4
The text was updated successfully, but these errors were encountered: