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

Frame hover glitch when moving on overlapping item border, with SetNextItemAllowOverlap #7515

Open
wolfgang371 opened this issue Apr 21, 2024 · 2 comments
Labels

Comments

@wolfgang371
Copy link

Version/Branch of Dear ImGui:

1.89.9 master

Back-ends:

crsfml, 2.5.3

Compiler, OS:

gcc/crystal, Ubuntu

Full config/build information:

No response

Details:

Below code produces something like this...

when moving down (bad):

220, hover top button
221, hover top button, hover bottom button
222, hover bottom button

when moving up (bad):

252, hover bottom button
253
254, hover top button

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

ImGui.set_next_item_allow_overlap # important
pos = ImGui.get_cursor_pos
ImGui.button("##button3", ImVec2.new(50.0,50.0))
h1 = ImGui.is_item_hovered
pos.y += 25
ImGui.set_cursor_pos(pos)
ImGui.button("##button4", ImVec2.new(50.0,50.0)) # button or dummy, irrelevant
# ImGui.dummy(ImVec2.new(50.0,50.0)) # button or dummy, irrelevant
h2 = ImGui.is_item_hovered
puts [ImGui.get_frame_count, h1 ? "hover top button" : nil, h2 ? "hover bottom button" : nil].reject(&.nil?).join(", ")
@ocornut ocornut changed the title Frame hover glitch when moving on overlapping item border, with set_next_item_allow_overlap Frame hover glitch when moving on overlapping item border, with SetNextItemAllowOverlap Apr 23, 2024
@ocornut
Copy link
Owner

ocornut commented Apr 23, 2024

Here's the C++ repro:

// #7515
{
    ImGui::SeparatorText("#7515");
    ImVec2 pos = ImGui::GetCursorPos();

    ImGui::SetNextItemAllowOverlap();
    ImGui::Button("button3", { 50.0f, 50.0f });
    bool h1 = ImGui::IsItemHovered();
    pos.y += 25;
    ImGui::SetCursorPos(pos);
    ImGui::Button("Button4", { 50.0f, 50.0f });// # button or dummy, irrelevant
    //ImGui::Dummy({ 50.0f, 50.0f });
    bool h2 = ImGui::IsItemHovered();
    if (h1 || h2)
        printf("[%05d] %s%s\n", ImGui::GetFrameCount(), h1 ? "hover top button" : "", h2 ? "hover bottom button" : "");
}

when moving down (bad):
220, hover top button
221, hover top button, hover bottom button
222, hover bottom button

I consider this an issue, let me investigate.

when moving up (bad):
252, hover bottom button
253
254, hover top button

This is the same as #7514 and I don't consider this an issue.

ocornut added a commit to ocornut/imgui_test_engine that referenced this issue Apr 23, 2024
@ocornut
Copy link
Owner

ocornut commented Apr 23, 2024

I have a pushed a test for the current behavior (which isn't necessarily correct)
ocornut/imgui_test_engine@33b9786
In particular I think the third section showcase the difference between IsItemHovered() and hover state as reported via ButtonBehavior()->ItemHoverable().

So if we introduce changes we can aim to validate them against current test and fix the test accordingly.

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

No branches or pull requests

2 participants