|
@@ -113,10 +113,13 @@ void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int a
|
|
|
g_PrevUserCallbackKey(window, key, scancode, action, mods);
|
|
|
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
- if (action == GLFW_PRESS)
|
|
|
- io.KeysDown[key] = true;
|
|
|
- if (action == GLFW_RELEASE)
|
|
|
- io.KeysDown[key] = false;
|
|
|
+ if (key >= 0 && key < IM_ARRAYSIZE(io.KeysDown))
|
|
|
+ {
|
|
|
+ if (action == GLFW_PRESS)
|
|
|
+ io.KeysDown[key] = true;
|
|
|
+ if (action == GLFW_RELEASE)
|
|
|
+ io.KeysDown[key] = false;
|
|
|
+ }
|
|
|
|
|
|
// Modifiers are not reliable across systems
|
|
|
io.KeyCtrl = io.KeysDown[GLFW_KEY_LEFT_CONTROL] || io.KeysDown[GLFW_KEY_RIGHT_CONTROL];
|