mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3664 from dumganhar/keyboard_test
[win32] glfw keyboard callback is enabled now. Enables KeyboardTest for win32.
This commit is contained in:
commit
4542732207
|
@ -280,6 +280,23 @@ void Layer::onAcceleration(Acceleration* pAccelerationValue, Event* event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layer::onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event)
|
||||||
|
{
|
||||||
|
CC_UNUSED_PARAM(keyCode);
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer::onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event)
|
||||||
|
{
|
||||||
|
CC_UNUSED_PARAM(event);
|
||||||
|
if(kScriptTypeNone != _scriptType)
|
||||||
|
{
|
||||||
|
KeypadScriptData data(keyCode, this);
|
||||||
|
ScriptEvent event(kKeypadEvent,&data);
|
||||||
|
ScriptEngineManager::getInstance()->getScriptEngine()->sendEvent(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// isKeyboardEnabled getter
|
/// isKeyboardEnabled getter
|
||||||
bool Layer::isKeyboardEnabled() const
|
bool Layer::isKeyboardEnabled() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,14 +145,15 @@ public:
|
||||||
|
|
||||||
virtual bool isKeyboardEnabled() const;
|
virtual bool isKeyboardEnabled() const;
|
||||||
virtual void setKeyboardEnabled(bool value);
|
virtual void setKeyboardEnabled(bool value);
|
||||||
|
|
||||||
/** Please use onKeyPressed instead. */
|
/** Please use onKeyPressed instead. */
|
||||||
virtual void keyPressed(int keyCode) final {};
|
virtual void keyPressed(int keyCode) final {};
|
||||||
|
|
||||||
/** Please use onKeyRelease instead. */
|
/** Please use onKeyReleased instead. */
|
||||||
virtual void keyReleased(int keyCode) final {};
|
virtual void keyReleased(int keyCode) final {};
|
||||||
|
|
||||||
virtual void onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event) {};
|
virtual void onKeyPressed(KeyboardEvent::KeyCode keyCode, Event* event);
|
||||||
virtual void onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event) {};
|
virtual void onKeyReleased(KeyboardEvent::KeyCode keyCode, Event* event);
|
||||||
|
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual bool isKeypadEnabled() const final { return false; };
|
CC_DEPRECATED_ATTRIBUTE virtual bool isKeypadEnabled() const final { return false; };
|
||||||
CC_DEPRECATED_ATTRIBUTE virtual void setKeypadEnabled(bool value) final {};
|
CC_DEPRECATED_ATTRIBUTE virtual void setKeypadEnabled(bool value) final {};
|
||||||
|
|
|
@ -35,12 +35,20 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap;// = {
|
struct keyCodeItem
|
||||||
|
{
|
||||||
|
int glfwKeyCode;
|
||||||
|
KeyboardEvent::KeyCode keyCode;
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap;
|
||||||
|
|
||||||
|
static keyCodeItem g_keyCodeStructArray[] = {
|
||||||
/* The unknown key */
|
/* The unknown key */
|
||||||
// make_pair( GLFW_KEY_UNKNOWN , KeyboardEvent::KeyCode::KEY_NONE ),
|
{ GLFW_KEY_UNKNOWN , KeyboardEvent::KeyCode::KEY_NONE },
|
||||||
|
|
||||||
/* Printable keys */
|
/* Printable keys */
|
||||||
/*
|
|
||||||
{ GLFW_KEY_SPACE , KeyboardEvent::KeyCode::KEY_SPACE },
|
{ GLFW_KEY_SPACE , KeyboardEvent::KeyCode::KEY_SPACE },
|
||||||
{ GLFW_KEY_APOSTROPHE , KeyboardEvent::KeyCode::KEY_APOSTROPHE },
|
{ GLFW_KEY_APOSTROPHE , KeyboardEvent::KeyCode::KEY_APOSTROPHE },
|
||||||
{ GLFW_KEY_COMMA , KeyboardEvent::KeyCode::KEY_COMMA },
|
{ GLFW_KEY_COMMA , KeyboardEvent::KeyCode::KEY_COMMA },
|
||||||
|
@ -92,7 +100,7 @@ static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap;// = {
|
||||||
{ GLFW_KEY_WORLD_1 , KeyboardEvent::KeyCode::KEY_GRAVE },
|
{ GLFW_KEY_WORLD_1 , KeyboardEvent::KeyCode::KEY_GRAVE },
|
||||||
{ GLFW_KEY_WORLD_2 , KeyboardEvent::KeyCode::KEY_NONE },
|
{ GLFW_KEY_WORLD_2 , KeyboardEvent::KeyCode::KEY_NONE },
|
||||||
|
|
||||||
/* Function keys *//*
|
/* Function keys */
|
||||||
{ GLFW_KEY_ESCAPE , KeyboardEvent::KeyCode::KEY_ESCAPE },
|
{ GLFW_KEY_ESCAPE , KeyboardEvent::KeyCode::KEY_ESCAPE },
|
||||||
{ GLFW_KEY_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER },
|
{ GLFW_KEY_ENTER , KeyboardEvent::KeyCode::KEY_KP_ENTER },
|
||||||
{ GLFW_KEY_TAB , KeyboardEvent::KeyCode::KEY_TAB },
|
{ GLFW_KEY_TAB , KeyboardEvent::KeyCode::KEY_TAB },
|
||||||
|
@ -163,8 +171,8 @@ static std::map<int, KeyboardEvent::KeyCode> g_keyCodeMap;// = {
|
||||||
{ GLFW_KEY_RIGHT_ALT , KeyboardEvent::KeyCode::KEY_ALT },
|
{ GLFW_KEY_RIGHT_ALT , KeyboardEvent::KeyCode::KEY_ALT },
|
||||||
{ GLFW_KEY_RIGHT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER },
|
{ GLFW_KEY_RIGHT_SUPER , KeyboardEvent::KeyCode::KEY_HYPER },
|
||||||
{ GLFW_KEY_MENU , KeyboardEvent::KeyCode::KEY_MENU },
|
{ GLFW_KEY_MENU , KeyboardEvent::KeyCode::KEY_MENU },
|
||||||
{ GLFW_KEY_LAST , KeyboardEvent::KeyCode::KEY_NONE }*/
|
{ GLFW_KEY_LAST , KeyboardEvent::KeyCode::KEY_NONE }
|
||||||
//};
|
};
|
||||||
|
|
||||||
#if(_MSC_VER >= 1600) // Visual Studio 2010 or higher version.
|
#if(_MSC_VER >= 1600) // Visual Studio 2010 or higher version.
|
||||||
// Windows Touch define
|
// Windows Touch define
|
||||||
|
@ -368,6 +376,11 @@ EGLView::EGLView()
|
||||||
{
|
{
|
||||||
CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n");
|
CCASSERT(nullptr == s_pEglView, "EGLView is singleton, Should be inited only one time\n");
|
||||||
s_pEglView = this;
|
s_pEglView = this;
|
||||||
|
g_keyCodeMap.clear();
|
||||||
|
for (auto& item : g_keyCodeStructArray)
|
||||||
|
{
|
||||||
|
g_keyCodeMap.insert(std::make_pair(item.glfwKeyCode, item.keyCode));
|
||||||
|
}
|
||||||
strcpy(_viewName, "Cocos2dxWin32");
|
strcpy(_viewName, "Cocos2dxWin32");
|
||||||
glfwSetErrorCallback(EGLViewEventHandler::OnGLFWError);
|
glfwSetErrorCallback(EGLViewEventHandler::OnGLFWError);
|
||||||
glfwInit();
|
glfwInit();
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "platform/CCCommon.h"
|
#include "platform/CCCommon.h"
|
||||||
#include "event_dispatcher/CCTouch.h"
|
#include "event_dispatcher/CCTouch.h"
|
||||||
#include "event_dispatcher/CCTouchEvent.h"
|
#include "event_dispatcher/CCTouchEvent.h"
|
||||||
|
#include "event_dispatcher/CCKeyboardEvent.h"
|
||||||
#include "cocoa/CCSet.h"
|
#include "cocoa/CCSet.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -291,7 +292,7 @@ struct TouchScriptData
|
||||||
|
|
||||||
struct KeypadScriptData
|
struct KeypadScriptData
|
||||||
{
|
{
|
||||||
int actionType;
|
KeyboardEvent::KeyCode actionType;
|
||||||
void* nativeObject;
|
void* nativeObject;
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
@ -299,7 +300,7 @@ struct KeypadScriptData
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
KeypadScriptData(int inActionType,void* inNativeObject)
|
KeypadScriptData(KeyboardEvent::KeyCode inActionType,void* inNativeObject)
|
||||||
: actionType(inActionType),nativeObject(inNativeObject)
|
: actionType(inActionType),nativeObject(inNativeObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ ArmatureDataManager *ArmatureDataManager::getInstance()
|
||||||
return s_sharedArmatureDataManager;
|
return s_sharedArmatureDataManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArmatureDataManager::purge()
|
void ArmatureDataManager::destoryInstance()
|
||||||
{
|
{
|
||||||
SpriteFrameCacheHelper::purge();
|
SpriteFrameCacheHelper::purge();
|
||||||
DataReaderHelper::purge();
|
DataReaderHelper::purge();
|
||||||
|
|
|
@ -40,9 +40,12 @@ public:
|
||||||
/** @deprecated Use getInstance() instead */
|
/** @deprecated Use getInstance() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE static ArmatureDataManager *sharedArmatureDataManager() { return ArmatureDataManager::getInstance(); }
|
CC_DEPRECATED_ATTRIBUTE static ArmatureDataManager *sharedArmatureDataManager() { return ArmatureDataManager::getInstance(); }
|
||||||
|
|
||||||
static ArmatureDataManager *getInstance();
|
/** @deprecated Use destoryInstance() instead */
|
||||||
|
CC_DEPRECATED_ATTRIBUTE static void purge() { ArmatureDataManager::destoryInstance(); };
|
||||||
|
|
||||||
|
static ArmatureDataManager *getInstance();
|
||||||
|
static void destoryInstance();
|
||||||
|
|
||||||
static void purge();
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* @js ctor
|
* @js ctor
|
||||||
|
|
|
@ -163,7 +163,7 @@ void ArmatureTestLayer::onEnter()
|
||||||
|
|
||||||
addChild(menu, 100);
|
addChild(menu, 100);
|
||||||
|
|
||||||
setShaderProgram(ShaderCache::getInstance()->programForKey(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
|
||||||
|
|
||||||
}
|
}
|
||||||
void ArmatureTestLayer::onExit()
|
void ArmatureTestLayer::onExit()
|
||||||
|
@ -171,6 +171,8 @@ void ArmatureTestLayer::onExit()
|
||||||
removeAllChildren();
|
removeAllChildren();
|
||||||
|
|
||||||
backItem = restartItem = nextItem = NULL;
|
backItem = restartItem = nextItem = NULL;
|
||||||
|
|
||||||
|
Layer::onExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ArmatureTestLayer::title()
|
std::string ArmatureTestLayer::title()
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#include "KeyboardTest.h"
|
#include "KeyboardTest.h"
|
||||||
|
|
||||||
#ifdef CC_KEYBOARD_SUPPORT
|
|
||||||
|
|
||||||
KeyboardTest::KeyboardTest()
|
KeyboardTest::KeyboardTest()
|
||||||
{
|
{
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
|
@ -43,4 +41,3 @@ void KeyboardTestScene::runThisTest()
|
||||||
layer->release();
|
layer->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef _KEYBOARD_TEST_H_
|
#ifndef _KEYBOARD_TEST_H_
|
||||||
#define _KEYBOARD_TEST_H_
|
#define _KEYBOARD_TEST_H_
|
||||||
|
|
||||||
#ifdef CC_KEYBOARD_SUPPORT
|
|
||||||
|
|
||||||
#include "cocos2d.h"
|
#include "cocos2d.h"
|
||||||
#include "../testBasic.h"
|
#include "../testBasic.h"
|
||||||
|
|
||||||
|
@ -25,6 +23,5 @@ public:
|
||||||
virtual void runThisTest();
|
virtual void runThisTest();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,7 +7,7 @@ KeypadTest::KeypadTest()
|
||||||
addChild(label, 0);
|
addChild(label, 0);
|
||||||
label->setPosition( Point(s.width/2, s.height-50) );
|
label->setPosition( Point(s.width/2, s.height-50) );
|
||||||
|
|
||||||
setKeypadEnabled(true);
|
setKeyboardEnabled(true);
|
||||||
|
|
||||||
// create a label to display the tip string
|
// create a label to display the tip string
|
||||||
_label = LabelTTF::create("Please press any key...", "Arial", 22);
|
_label = LabelTTF::create("Please press any key...", "Arial", 22);
|
||||||
|
|
|
@ -50,9 +50,7 @@ struct {
|
||||||
{ "FileUtilsTest", []() { return new FileUtilsTestScene(); } },
|
{ "FileUtilsTest", []() { return new FileUtilsTestScene(); } },
|
||||||
{ "FontTest", []() { return new FontTestScene(); } },
|
{ "FontTest", []() { return new FontTestScene(); } },
|
||||||
{ "IntervalTest", [](){return new IntervalTestScene(); } },
|
{ "IntervalTest", [](){return new IntervalTestScene(); } },
|
||||||
#ifdef CC_KEYBOARD_SUPPORT
|
|
||||||
{ "KeyboardTest", []() { return new KeyboardTestScene(); } },
|
{ "KeyboardTest", []() { return new KeyboardTestScene(); } },
|
||||||
#endif
|
|
||||||
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
|
#if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA)
|
||||||
{ "KeypadTest", []() { return new KeypadTestScene(); } },
|
{ "KeypadTest", []() { return new KeypadTestScene(); } },
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "testBasic.h"
|
#include "testBasic.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
#include "cocos-ext.h"
|
||||||
|
|
||||||
TestScene::TestScene(bool bPortrait)
|
TestScene::TestScene(bool bPortrait)
|
||||||
{
|
{
|
||||||
|
@ -48,6 +49,8 @@ void TestScene::onEnter()
|
||||||
Director::getInstance()->replaceScene(scene);
|
Director::getInstance()->replaceScene(scene);
|
||||||
scene->release();
|
scene->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cocos2d::extension::armature::ArmatureDataManager::destoryInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
auto menu =Menu::create(menuItem, NULL);
|
auto menu =Menu::create(menuItem, NULL);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "VisibleRect.h"
|
#include "VisibleRect.h"
|
||||||
|
|
||||||
USING_NS_CC;
|
USING_NS_CC;
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
class TestScene : public Scene
|
class TestScene : public Scene
|
||||||
|
|
|
@ -31,9 +31,7 @@
|
||||||
#include "EffectsAdvancedTest/EffectsAdvancedTest.h"
|
#include "EffectsAdvancedTest/EffectsAdvancedTest.h"
|
||||||
#include "AccelerometerTest/AccelerometerTest.h"
|
#include "AccelerometerTest/AccelerometerTest.h"
|
||||||
#include "KeypadTest/KeypadTest.h"
|
#include "KeypadTest/KeypadTest.h"
|
||||||
#ifdef CC_KEYBOARD_SUPPORT
|
|
||||||
#include "KeyboardTest/KeyboardTest.h"
|
#include "KeyboardTest/KeyboardTest.h"
|
||||||
#endif
|
|
||||||
#include "PerformanceTest/PerformanceTest.h"
|
#include "PerformanceTest/PerformanceTest.h"
|
||||||
#include "ZwoptexTest/ZwoptexTest.h"
|
#include "ZwoptexTest/ZwoptexTest.h"
|
||||||
#include "CocosDenshionTest/CocosDenshionTest.h"
|
#include "CocosDenshionTest/CocosDenshionTest.h"
|
||||||
|
|
|
@ -177,6 +177,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\TableViewTest\CustomTableViewCell.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\TableViewTest\CustomTableViewCell.cpp" />
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\TableViewTest\TableViewTestScene.cpp" />
|
<ClCompile Include="..\Classes\ExtensionsTest\TableViewTest\TableViewTestScene.cpp" />
|
||||||
<ClCompile Include="..\Classes\FileUtilsTest\FileUtilsTest.cpp" />
|
<ClCompile Include="..\Classes\FileUtilsTest\FileUtilsTest.cpp" />
|
||||||
|
<ClCompile Include="..\Classes\KeyboardTest\KeyboardTest.cpp" />
|
||||||
<ClCompile Include="..\Classes\LabelTest\LabelTestNew.cpp" />
|
<ClCompile Include="..\Classes\LabelTest\LabelTestNew.cpp" />
|
||||||
<ClCompile Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.cpp" />
|
<ClCompile Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.cpp" />
|
||||||
<ClCompile Include="..\Classes\PerformanceTest\PerformanceAllocTest.cpp" />
|
<ClCompile Include="..\Classes\PerformanceTest\PerformanceAllocTest.cpp" />
|
||||||
|
@ -312,6 +313,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\libwebsockets\win32\lib\*.*" "$(O
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\TableViewTest\CustomTableViewCell.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\TableViewTest\CustomTableViewCell.h" />
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\TableViewTest\TableViewTestScene.h" />
|
<ClInclude Include="..\Classes\ExtensionsTest\TableViewTest\TableViewTestScene.h" />
|
||||||
<ClInclude Include="..\Classes\FileUtilsTest\FileUtilsTest.h" />
|
<ClInclude Include="..\Classes\FileUtilsTest\FileUtilsTest.h" />
|
||||||
|
<ClInclude Include="..\Classes\KeyboardTest\KeyboardTest.h" />
|
||||||
<ClInclude Include="..\Classes\LabelTest\LabelTestNew.h" />
|
<ClInclude Include="..\Classes\LabelTest\LabelTestNew.h" />
|
||||||
<ClInclude Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.h" />
|
<ClInclude Include="..\Classes\NewEventDispatcherTest\NewEventDispatcherTest.h" />
|
||||||
<ClInclude Include="..\Classes\PhysicsTest\PhysicsTest.h" />
|
<ClInclude Include="..\Classes\PhysicsTest\PhysicsTest.h" />
|
||||||
|
|
|
@ -297,6 +297,9 @@
|
||||||
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest">
|
<Filter Include="Classes\ExtensionsTest\CocoStudioGUITest\UIButtonTest">
|
||||||
<UniqueIdentifier>{24f044ee-09a6-406b-98d7-8d5d759e5bb1}</UniqueIdentifier>
|
<UniqueIdentifier>{24f044ee-09a6-406b-98d7-8d5d759e5bb1}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Classes\KeyboardTest">
|
||||||
|
<UniqueIdentifier>{8d7d37cd-5cc2-4a7d-9bd2-7b5c928adbb5}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
|
@ -689,6 +692,9 @@
|
||||||
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.cpp">
|
<ClCompile Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.cpp">
|
||||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Classes\KeyboardTest\KeyboardTest.cpp">
|
||||||
|
<Filter>Classes\KeyboardTest</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="main.h">
|
<ClInclude Include="main.h">
|
||||||
|
@ -1258,5 +1264,8 @@
|
||||||
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.h">
|
<ClInclude Include="..\Classes\ExtensionsTest\CocoStudioGUITest\UISceneManager.h">
|
||||||
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
<Filter>Classes\ExtensionsTest\CocoStudioGUITest</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\Classes\KeyboardTest\KeyboardTest.h">
|
||||||
|
<Filter>Classes\KeyboardTest</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1 +1 @@
|
||||||
febc64c0af18af645de925396d73473973a0b37e
|
968b4fa41bd81c391c5cbcd17d8e5d40f7d7c02e
|
|
@ -980,23 +980,40 @@ int ScriptingCore::handleKeypadEvent(void* data)
|
||||||
if (NULL == keypadScriptData->nativeObject)
|
if (NULL == keypadScriptData->nativeObject)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int action = keypadScriptData->actionType;
|
KeyboardEvent::KeyCode action = keypadScriptData->actionType;
|
||||||
|
|
||||||
js_proxy_t * p = jsb_get_native_proxy(keypadScriptData->nativeObject);
|
js_proxy_t * p = jsb_get_native_proxy(keypadScriptData->nativeObject);
|
||||||
|
|
||||||
if (p)
|
if (p)
|
||||||
{
|
{
|
||||||
// FIXME: switch(action)
|
JSBool ret = JS_FALSE;
|
||||||
// {
|
switch(action)
|
||||||
// case kTypeBackClicked:
|
{
|
||||||
// executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "backClicked");
|
case KeyboardEvent::KeyCode::KEY_BACKSPACE:
|
||||||
// break;
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onBackClicked");
|
||||||
// case kTypeMenuClicked:
|
if (!ret)
|
||||||
// executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "menuClicked");
|
{
|
||||||
// break;
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "backClicked");
|
||||||
// default:
|
if (ret)
|
||||||
// break;
|
{
|
||||||
// }
|
CCLOG("backClicked will be deprecated, please use onBackClicked instead.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KeyboardEvent::KeyCode::KEY_MENU:
|
||||||
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onMenuClicked");
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "menuClicked");
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
CCLOG("menuClicked will be deprecated, please use onMenuClicked instead.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,4 +64,14 @@ var cc = cc || {};
|
||||||
cc.log("cc.Menu.setHandlerPriority was deprecated, 3.0 uses new event dispatcher to dispatch touch event based on draw order, so setHandlerPriority is not needed now.");
|
cc.log("cc.Menu.setHandlerPriority was deprecated, 3.0 uses new event dispatcher to dispatch touch event based on draw order, so setHandlerPriority is not needed now.");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cc.Layer.prototype.setKeypadEnabled = function() {
|
||||||
|
logW("cc.Layer.setKeypadEnabled", "cc.Layer.setKeyboardEnabled");
|
||||||
|
return cc.Layer.prototype.setKeyboardEnabled.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
cc.Layer.prototype.isKeypadEnabled = function() {
|
||||||
|
logW("cc.Layer.isKeypadEnabled", "cc.Layer.isKeyboardEnabled");
|
||||||
|
return cc.Layer.prototype.isKeyboardEnabled.apply(this, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -400,22 +400,20 @@ int LuaEngine::handleKeypadEvent(void* data)
|
||||||
if (0 == handler)
|
if (0 == handler)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int action = keypadScriptData->actionType;
|
KeyboardEvent::KeyCode action = keypadScriptData->actionType;
|
||||||
|
|
||||||
|
switch(action)
|
||||||
|
{
|
||||||
|
case KeyboardEvent::KeyCode::KEY_BACKSPACE:
|
||||||
|
_stack->pushString("backClicked");
|
||||||
|
break;
|
||||||
|
case KeyboardEvent::KeyCode::KEY_MENU:
|
||||||
|
_stack->pushString("menuClicked");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
//FIXME:
|
|
||||||
// switch (action)
|
|
||||||
// {
|
|
||||||
// case kTypeBackClicked:
|
|
||||||
// _stack->pushString("backClicked");
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// case kTypeMenuClicked:
|
|
||||||
// _stack->pushString("menuClicked");
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
// default:
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
int ret = _stack->executeFunctionByHandler(handler, 1);
|
int ret = _stack->executeFunctionByHandler(handler, 1);
|
||||||
_stack->clean();
|
_stack->clean();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue