From e51a0a80ca89e21eb48c17d5be5185c890233f99 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 13 Jan 2022 18:42:18 +0100 Subject: [PATCH] IO: fix SetKeyEventNativeData() not handling ImGuiKey_None the same way as AddKeyEvent(). (#4905, #4858) --- imgui.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 91c97b6c..f319188f 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1302,6 +1302,8 @@ void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down) // If you are writing a backend in 2022 or don't use IsKeyXXX() with native values that are not ImGuiKey values, you can avoid calling this. void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index) { + if (key == ImGuiKey_None) + return; IM_ASSERT(ImGui::IsNamedKey(key)); // >= 512 IM_ASSERT(native_legacy_index == -1 || ImGui::IsLegacyKey(native_legacy_index)); // >= 0 && <= 511 IM_UNUSED(native_keycode); // Yet unused