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

ImGui::Button doesn't apply ImGuiCol_TextDisabled color when ImGuiItemFlags_Disabled is set #5240

Closed
peter1745 opened this issue Apr 24, 2022 · 2 comments
Labels

Comments

@peter1745
Copy link

Version/Branch of Dear ImGui:

Version: 1.87 (18701)
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_vulkan_with_textures.cpp
Compiler: MSVC
Operating System: Windows 11

My Issue:
Currently when setting a button to be disabled, it does prevent the user from clicking it, and it doesn't respond to hover / focus. But at the moment it doesn't change the text color to the disabled color (ImGuiCol_TextDisabled).
While it's simple to hack around this (just set ImGuiCol_Text to have the same value as ImGuiCol_TextDisabled), it's not the expected behavior.

Example code to reproduce:

static bool disableButton = false;
ImGui::Checkbox("Disabled", &disableButton);
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, disableButton);
ImGui::Button("Some Button");
ImGui::PopItemFlag();
@ocornut ocornut added the style label Apr 25, 2022
@ocornut
Copy link
Owner

ocornut commented Apr 25, 2022

As per #4478 (comment) and generally #211 the existence of ImGuiCol_TextDisabled became a little inconsistent with the new BeginDisabled()/EndDisabled() API. Generally we don't expect ImGuiCol_TextDisabled to be used much (until we redesign styling).

ImGui::PushItemFlag(ImGuiItemFlags_Disabled, disableButton); is an internal/documented API which only alter interactions.
See the comment

ImGuiItemFlags_Disabled = 1 << 2, // Disable interactions but doesn't affect visuals. See BeginDisabled()/EndDisabled(). See github.com/ocornut/imgui/issues/211

You should use BeginDisabled()/EndDisabled() it will have an effect on all colors.

@peter1745
Copy link
Author

Ah, hadn't noticed that one, I'll be sure to switch to using that! Thanks for the quick reply 🙂

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