Skip to content

Buttons can still be clicked when they are disabled #496

@adriengivry

Description

@adriengivry

Description

It seems like since the latest ImGui update, buttons that are supposed to be disabled are still clickable.

There are many cases, including (non-exhaustive):

  • "Add Script" button in inspector
  • Toolbar buttons
  • etc...

Expecting the fix to be somewhere in there:

void OvUI::Widgets::Buttons::Button::_Draw_Impl()
{
auto& style = ImGui::GetStyle();
auto defaultIdleColor = style.Colors[ImGuiCol_Button];
auto defaultHoveredColor = style.Colors[ImGuiCol_ButtonHovered];
auto defaultClickedColor = style.Colors[ImGuiCol_ButtonActive];
auto defaultTextColor = style.Colors[ImGuiCol_Text];
style.Colors[ImGuiCol_Button] = OvUI::Internal::Converter::ToImVec4(idleBackgroundColor);
style.Colors[ImGuiCol_ButtonHovered] = OvUI::Internal::Converter::ToImVec4(hoveredBackgroundColor);
style.Colors[ImGuiCol_ButtonActive] = OvUI::Internal::Converter::ToImVec4(clickedBackgroundColor);
style.Colors[ImGuiCol_Text] = OvUI::Internal::Converter::ToImVec4(textColor);
if (ImGui::ButtonEx((label + m_widgetID).c_str(), Internal::Converter::ToImVec2(size), disabled ? ImGuiItemFlags_Disabled : 0))
ClickedEvent.Invoke();
style.Colors[ImGuiCol_Button] = defaultIdleColor;
style.Colors[ImGuiCol_ButtonHovered] = defaultHoveredColor;
style.Colors[ImGuiCol_ButtonActive] = defaultClickedColor;
style.Colors[ImGuiCol_Text] = defaultTextColor;
}

To Reproduce

Steps to reproduce the behavior:

  1. Open the editor
  2. Click on the "pause" button in the toolbar
  3. Notice the issue

Expected behavior

A button marked as "disabled" shouldn't be clickable.

Screenshots

OvEditor_HR8QZhjW03.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    EditorSomething relative with the editorGood First IssueAn easy issue for new contributors

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions