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

ImGuiItemFlags_Disabled makes items not hoverable, blocks ability to give user feedback #1940

Closed
mswf opened this issue Jul 10, 2018 · 2 comments

Comments

@mswf
Copy link

mswf commented Jul 10, 2018

Version/Branch of Dear ImGui:

1.62

My Issue/Question:
I would like to use the _Disabled flag, but would also like to give the user feedback on why an item is disabled. When ItemHovered() sees that the item you're checking has ImGuiItemFlags_Disabled, it always returns false. This makes it harder (workaround is possible of course) to show a tooltip and/or provide more feedback.

I understand that the _Disabled flag is WIP functionality which is why I brought it up here first for review instead of opening a pull request.
After a few tests, I didn't spot unintended behavior after removing the check for _Disabled from ItemHovered(), but then I wasn't sure if it should also be removed from ItemHoverable() for "consistencies' sake". I didn't see any comments/issues discussing this, so I wanted to ask here if anybody knows any good reason to keep the code as is.

Standalone, minimal, complete and verifiable example:

ImGui::SetDisabled();
ImGui::Button("Blocked Action");
if (ImGui::IsItemHovered())
{
    // Never happens ;(
    ImGui::SetTooltip("This Action is Blocked because _bla_bla_");
}
ImGui::UnsetDisabled()

The offending(?) code:

bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
{
...
    // Test if the item is disabled
    if (window->DC.ItemFlags & ImGuiItemFlags_Disabled)
        return false;
...
}

If I get confirmation that there is no reason for disabling hover on disabled items, I will open a PR. If this part would/could get changed I would get exactly what I need out of the SetDisabled functionality already.

P.S. Thank you for ImGUI, it's enabling me to work on a very cool project that probably couldn't have gotten off the ground without this lovely library.

@ocornut
Copy link
Owner

ocornut commented Jul 10, 2018

Hello Steff,

Thanks for the feedback.

I agree we should make this possible, but given the nature of the feature I think IsItemHovered() should return false by default because it may trigger various behavior on the user code.

However, we can add a new explicit flag so IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) will bypass the check and that's a trivial change I can make now.

(Linking to #211 for later reference)

ocornut added a commit that referenced this issue Jul 10, 2018
…ery hovered status on disabled items. (#1940, #211)

+ shallow changelog tweaks
@ocornut ocornut closed this as completed Jul 13, 2018
@ocornut ocornut reopened this Jun 9, 2021
@ocornut
Copy link
Owner

ocornut commented Jul 8, 2021

Not sure why this was reopened, this is solved but there's still work to do for #3419

@ocornut ocornut closed this as completed Jul 8, 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