Buttons can be clicked via the keyboard when disabled dynamically (already focused)
Closed this issue · 1 comments
YclepticStudios commented
Version/Branch of Dear ImGui:
Version 1.92.2b, Branch: docking, Tag: v1.92.2b-docking
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Linux + g++ 13.3.0
Full config/build information:
Dear ImGui 1.92.2b (19222)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __linux__
define: __GNUC__=13
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_glfw (3310)
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000483
NavEnableKeyboard
NavEnableGamepad
DockingEnable
ViewportsEnable
io.ConfigDpiScaleFonts
io.ConfigDpiScaleViewports
io.ConfigViewportsNoDecoration
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C1E
HasMouseCursors
HasSetMousePos
PlatformHasViewports
HasMouseHoveredViewport
RendererHasVtxOffset
RendererHasTextures
RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1280.00,800.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00Details:
My Issue/Question:
Hello and thank you for the great library! I have encountered what I believe to be a bug where if a button is disabled while it holds keyboard focus, you can continue to action the button while it is in its disabled state by pressing "space".
Steps to Reproduce Using Below Example:
- Navigate to the button using "tab" so that it holds focus.
- Use "space" to action the button causing it to become disabled.
- Use "space" to action the disabled button.
- Expectation: Button should not be able to be clicked while disabled.
- Reality: Button can still be clicked with keyboard inputs.
Screenshots/Video:
Screencast.from.2025-10-26.08-48-38.webm
Minimal, Complete and Verifiable Example code:
The following code snippet is a modification of the example_glfw_opengl3/main.cpp file. I have included a small amount of context to illustrate where in the file it is inserted.
// 1. Show the big demo window (Most of the sample code is in
// ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear
// ImGui!).
if (show_demo_window)
ImGui::ShowDemoWindow(&show_demo_window);
// ========= BEGIN REPRODUCTION ========= //
{
static bool disabled = false;
ImGui::Begin("Bug Report Window");
ImGui::BeginDisabled(disabled);
if (ImGui::Button("Click me with the keyboard")) {
if (disabled) {
printf("Button was clicked while disabled!!!\n");
}
disabled = !disabled;
}
ImGui::EndDisabled();
ImGui::End();
}
// ========= END REPRODUCTION ========= //
// 2. Show a simple window that we create ourselves. We use a Begin/End pair
// to create a named window.
{