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

HoveredIdTimer doesn't increment on disabled items #3419

Closed
s9w opened this issue Aug 19, 2020 · 2 comments
Closed

HoveredIdTimer doesn't increment on disabled items #3419

s9w opened this issue Aug 19, 2020 · 2 comments

Comments

@s9w
Copy link

s9w commented Aug 19, 2020

Version/Branch of Dear ImGui:
Version: 1.77
Branch: master

Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Operating System: Win10

My Issue/Question:
For #1940, there was the new ImGuiHoveredFlags_AllowWhenDisabled added. That works very well to allow feedback on disabled buttons etc. Unrelated to that, in #1485 there was a way posted to implement delayed tooltips by using GImGui->HoveredIdTimer. However that HoveredIdTimer does not increment with disabled Buttons.

I'm not 100% sure that it is supposed to, although it seems reasonable.

Standalone, minimal, complete and verifiable example:

ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::Button("disabled!");
ImGui::PopItemFlag();

if(ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) &&
   GImGui->HoveredIdTimer >= delay)
{
   // GImGui->HoveredIdTimer is always 0.0, hence this only works with delay==0.0
}
@ocornut ocornut changed the title ImGuiHoveredFlags_AllowWhenDisabled doesn't increase HoveredIdTimer HoveredIdTimer doesn't increment on disabled items Aug 21, 2020
@ocornut
Copy link
Owner

ocornut commented Aug 26, 2020

Hello,

FYI i have renamed the topic has this technically doesn't have anything to do with ImGuiHoveredFlags_AllowWhenDisabled, it's generally that g.HoveredID is not set on disabled item and therefore g.HoveredIdTimer won't increment.

But somehow the way IsItemHovered() work will work on disabled item - as IsItemHovered() works on items that don't have ID, it's pulling the last item data which is filled regardless of the value of g.HoveredId and disabled state.

I think we should change the code to fill g.HoveredId on disabled item but this may have a few side effects so need to be done carefully. In fact we have a branch by @rokups that attempted to do that already (initially for a different reason). I will try to review their work on that.

ocornut pushed a commit that referenced this issue Jul 9, 2021
…to function. (#211, #3419) + Menus: fix hovering a disabled menu or menu item not closing other menus.

Rework of rokups@c24b470
Note that the declared intent of that commit "Prevents window from being dragged if mouse hovers a disabled item." was already fullfilled by a876ad8.
Changes in ButtonBehavior() not needed anymore since ImGuiButtonFlags_Disabled is gone
@ocornut
Copy link
Owner

ocornut commented Jul 9, 2021

This is now fixed by 5dd1e38.

@ocornut ocornut closed this as completed Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants