diff --git a/backends/imgui_impl_osx.mm b/backends/imgui_impl_osx.mm index 4ef44c5fc..394cd0de8 100644 --- a/backends/imgui_impl_osx.mm +++ b/backends/imgui_impl_osx.mm @@ -603,9 +603,10 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view) if ([event isARepeat]) return io.WantCaptureKeyboard; + int key_code = (int)[event keyCode]; ImGuiKey key = ImGui_ImplOSX_KeyCodeToImGuiKey(key_code); io.AddKeyEvent(key, event.type == NSEventTypeKeyDown); - io.SetKeyEventNativeData(key, (int)[event keyCode], -1); // To support legacy indexing (<1.87 user code) + io.SetKeyEventNativeData(key, key_code, -1); // To support legacy indexing (<1.87 user code) return io.WantCaptureKeyboard; } diff --git a/imgui.cpp b/imgui.cpp index dc51a320c..aa24c1186 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7435,6 +7435,8 @@ const char* ImGui::GetKeyName(ImGuiKey key) #endif if (key == ImGuiKey_None) return "None"; + if (!IsNamedKey(key)) + return "Unknown"; return GKeyNames[key - ImGuiKey_NamedKey_BEGIN]; } @@ -9717,6 +9719,18 @@ static ImVec2 ImGui::NavCalcPreferredRefPos() } } +const char* ImGui::GetNavInputName(ImGuiNavInput n) +{ + static const char* names[] = + { + "Activate", "Cancel", "Input", "Menu", "DpadLeft", "DpadRight", "DpadUp", "DpadDown", "LStickLeft", "LStickRight", "LStickUp", "LStickDown", + "FocusPrev", "FocusNext", "TweakSlow", "TweakFast", "KeyLeft", "KeyRight", "KeyUp", "KeyDown" + }; + IM_ASSERT(IM_ARRAYSIZE(names) == ImGuiNavInput_COUNT); + IM_ASSERT(n >= 0 && n < ImGuiNavInput_COUNT); + return names[n]; +} + float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode) { ImGuiContext& g = *GImGui; diff --git a/imgui.h b/imgui.h index 064ff3b85..2775a0f3f 100644 --- a/imgui.h +++ b/imgui.h @@ -65,7 +65,7 @@ Index of this file: // Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) #define IMGUI_VERSION "1.87 WIP" -#define IMGUI_VERSION_NUM 18604 +#define IMGUI_VERSION_NUM 18605 #define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) #define IMGUI_HAS_TABLE @@ -1523,8 +1523,7 @@ enum ImGuiNavInput_ ImGuiNavInput_KeyRight_, // Move right ImGuiNavInput_KeyUp_, // Move up ImGuiNavInput_KeyDown_, // Move down - ImGuiNavInput_COUNT, - ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyLeft_ + ImGuiNavInput_COUNT }; // Configuration flags stored in io.ConfigFlags. Set by user/application. diff --git a/imgui_internal.h b/imgui_internal.h index d725c90f9..80fd75d55 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2577,6 +2577,7 @@ namespace ImGui IMGUI_API void NavMoveRequestCancel(); IMGUI_API void NavMoveRequestApplyResult(); IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags); + IMGUI_API const char* GetNavInputName(ImGuiNavInput n); IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode); IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f); IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);