-
-
Notifications
You must be signed in to change notification settings - Fork 11.4k
Closed
Labels
Description
Version/Branch of Dear ImGui:
Version 1.92.6 WIP, Branch: docking
Back-ends:
imgui_impl_win32.cpp + imgui_impl_opengl3.cpp
Compiler, OS:
Windows11 + MSVC2022
Full config/build information:
Dear ImGui 1.92.6 WIP (19255)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1944
define: _MSVC_LANG=202002
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
IM_ASSERT: runs expression: OK. expand size: OK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_opengl3
io.ConfigFlags: 0x00000483
NavEnableKeyboard
NavEnableGamepad
DockingEnable
ViewportsEnable
io.ConfigDpiScaleFonts
io.ConfigDpiScaleViewports
io.ConfigViewportsNoDecoration
io.ConfigViewportsNoDefaultParent
io.ConfigNavCaptureKeyboard
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00003C1E
HasMouseCursors
HasSetMousePos
PlatformHasViewports
HasMouseHoveredViewport
HasParentViewport
RendererHasVtxOffset
RendererHasTextures
RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,128
io.Fonts->FontLoaderName: stb_truetype
io.DisplaySize: 1264.00,761.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:
Issue
When I execute ImGui::MenuItem with the Enter key and open a FileDialog, the Enter key remains pressed after the FileDialog is closed.
This issue does not occur when using the left mouse button. the left button does not stay pressed.
Additionally, this problem occurs with the Win32 backend but does not occur with the GLFW backend.
Reproduction Steps
- Left‑click the File menu.
- Press the Down Arrow key.
- Press Enter to open the FileDialog.
- Left‑click Cancel to close the FileDialog.
My Actual Problem
- Ctrl + Z and Ctrl + Y are assigned to Undo and Redo.
- When the Undo/Redo operation is heavy, a progress‑bar dialog window owned by the main window is displayed.
- After the dialog is closed, Ctrl + Z remains pressed.
- Similarly, when pressing Ctrl + Y, Ctrl + Y remains pressed after the dialog is closed.
- Undo and Redo are repeated alternately, since Ctrl + Z and Ctrl + Y remain pressed.
I guess this issue can be avoided by using an ImGui PopupModal instead of a Win32 owned window.
However, I am unsure whether the key remaining pressed is a bug or intended behavior, and I would like to know.
Screenshots/Video:
Win32 backend
GLFW backend
Minimal, Complete and Verifiable Example code:
Win32 backend
#include <Windows.h>
#include <commdlg.h>
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
if (ImGui::BeginMainMenuBar()) {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open...")) {
OPENFILENAMEA open_file = { 0 };
char file_name[MAX_PATH] = "";
open_file.lStructSize = sizeof(OPENFILENAMEA);
open_file.hwndOwner = hwnd;
open_file.lpstrFile = file_name;
open_file.nMaxFile = sizeof(file_name);
open_file.lpstrFilter = nullptr;
open_file.Flags = OFN_FILEMUSTEXIST;
open_file.lpstrTitle = "Open";
if (!GetOpenFileNameA(&open_file)) {
}
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
// 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);GLFW backend
#include <Windows.h>
#include <commdlg.h>
#include <GLFW/glfw3.h> // Will drag system OpenGL headers
#define GLFW_EXPOSE_NATIVE_WIN32
#include <GLFW/glfw3native.h>
// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplGlfw_NewFrame();
ImGui::NewFrame();
if (ImGui::BeginMainMenuBar()) {
if (ImGui::BeginMenu("File")) {
if (ImGui::MenuItem("Open...")) {
OPENFILENAMEA open_file = { 0 };
char file_name[MAX_PATH] = "";
open_file.lStructSize = sizeof(OPENFILENAMEA);
open_file.hwndOwner = glfwGetWin32Window(window);
open_file.lpstrFile = file_name;
open_file.nMaxFile = sizeof(file_name);
open_file.lpstrFilter = nullptr;
open_file.Flags = OFN_FILEMUSTEXIST;
open_file.lpstrTitle = "Open";
if (!GetOpenFileNameA(&open_file)) {
}
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
// 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);
