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 adjacent item border, with SetNextItemAllowOverlap #7514

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

Comments

@wolfgang371
Copy link

wolfgang371 commented Apr 21, 2024

ImGui.set_next_item_allow_overlap # important
ImGui.button("##button1", ImVec2.new(50.0,50.0))
h1 = ImGui.is_item_hovered
ImGui.button("##button2", 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(", ")

produces something like this...

when moving down (good)

185, hover top button
186, hover bottom button

when moving up (bad)

194, hover bottom button
195
196, hover top button

Version/Branch of Dear ImGui: 1.89.9 master
Back-ends: crsfml, 2.5.3
Compiler, OS: gcc/crystal, Ubuntu

@ocornut ocornut changed the title Frame hover glitch when moving on adjacent item border, with set_next_item_allow_overlap Frame hover glitch when moving on adjacent item border, with SetNextItemAllowOverlap Apr 23, 2024
@ocornut
Copy link
Owner

ocornut commented Apr 23, 2024

Hello,

This is expected with how AllowOverlap mode is implemented. It requires an extra frame before hovering starts being reported, to ensure a subsequent item is not overlapping our item. I don't expect to be able to change this.

(I know this is a manufactured repro, and it's great submitted as is! But obviously in your example the button are not overlapping. I wonder what your actual problem encompassing the several overlap-related issues is)

C++ repro

// #7514
{
    ImGui::SeparatorText("#7514");
    ImGui::SetNextItemAllowOverlap();
    ImGui::Button("Button1", { 50.0f, 50.0 });
    bool h1 = ImGui::IsItemHovered();
    ImGui::Button("Button2", { 50.0, 50.0 });// # button or dummy, irrelevant
    //ImGui::Dummy({ 50.0, 50.0});// # button or dummy, irrelevant
    bool h2 = ImGui::IsItemHovered();
    //if (h1 || h2)
    if (ImGui::IsWindowHovered())
        printf("[%05d] %s%s\n", ImGui::GetFrameCount(), h1 ? "hover top button" : "", h2 ? "hover bottom button" : "");
}

@wolfgang371
Copy link
Author

Hi @ocornut,
thanks for having a look - regarding your question (my actual problem) / just for the record: this is related to #7510.
With the glitch from above and some of the workarounds from the other issue, the hovered InputText would "blink out" for one frame - not a big deal/nuisance, sure.

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