From ffad18a1eddb16d84bf94ebda48ffe7a2e2c1982 Mon Sep 17 00:00:00 2001 From: Michael Contento Date: Sat, 2 Nov 2013 06:15:08 +0100 Subject: [PATCH] Trigger onKeyReleased only after the key has been released --- cocos/2d/platform/linux/CCEGLView.cpp | 2 +- cocos/2d/platform/mac/CCEGLView.mm | 2 +- cocos/2d/platform/win32/CCEGLView.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/2d/platform/linux/CCEGLView.cpp b/cocos/2d/platform/linux/CCEGLView.cpp index ed1b2b6ddb..33b8796959 100644 --- a/cocos/2d/platform/linux/CCEGLView.cpp +++ b/cocos/2d/platform/linux/CCEGLView.cpp @@ -256,7 +256,7 @@ void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); + EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action || GLFW_REPEAT == action); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); } diff --git a/cocos/2d/platform/mac/CCEGLView.mm b/cocos/2d/platform/mac/CCEGLView.mm index 63bc94a43d..af3863476d 100644 --- a/cocos/2d/platform/mac/CCEGLView.mm +++ b/cocos/2d/platform/mac/CCEGLView.mm @@ -274,7 +274,7 @@ void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); + EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action || GLFW_REPEAT == action); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); } diff --git a/cocos/2d/platform/win32/CCEGLView.cpp b/cocos/2d/platform/win32/CCEGLView.cpp index b84d87c554..6b19ec5bb5 100644 --- a/cocos/2d/platform/win32/CCEGLView.cpp +++ b/cocos/2d/platform/win32/CCEGLView.cpp @@ -373,7 +373,7 @@ void EGLViewEventHandler::OnGLFWMouseScrollCallback(GLFWwindow* window, double x void EGLViewEventHandler::OnGLFWKeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { - EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action); + EventKeyboard event(g_keyCodeMap[key], GLFW_PRESS == action || GLFW_REPEAT == action); auto dispatcher = Director::getInstance()->getEventDispatcher(); dispatcher->dispatchEvent(&event); }