2012-04-19 14:35:52 +08:00
|
|
|
#include "KeypadTest.h"
|
|
|
|
|
|
|
|
KeypadTest::KeypadTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto s = Director::getInstance()->getWinSize();
|
|
|
|
auto label = LabelTTF::create("Keypad Test", "Arial", 28);
|
2012-04-19 14:35:52 +08:00
|
|
|
addChild(label, 0);
|
2013-07-12 14:11:55 +08:00
|
|
|
label->setPosition( Point(s.width/2, s.height-50) );
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-09-17 22:34:20 +08:00
|
|
|
setKeyboardEnabled(true);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// create a label to display the tip string
|
2013-06-20 14:17:10 +08:00
|
|
|
_label = LabelTTF::create("Please press any key...", "Arial", 22);
|
2013-07-12 14:11:55 +08:00
|
|
|
_label->setPosition(Point(s.width / 2, s.height / 2));
|
2013-06-15 14:03:30 +08:00
|
|
|
addChild(_label, 0);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->retain();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
KeypadTest::~KeypadTest()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_label->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
void KeypadTest::onKeyReleased(KeyboardEvent::KeyCode keycode, Event* event)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-09-03 18:22:03 +08:00
|
|
|
if (keycode == KeyboardEvent::KeyCode::KEY_BACKSPACE)
|
|
|
|
{
|
|
|
|
_label->setString("BACK clicked!");
|
|
|
|
}
|
|
|
|
else if (keycode == KeyboardEvent::KeyCode::KEY_MENU)
|
|
|
|
{
|
|
|
|
_label->setString("MENU clicked!");
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void KeypadTestScene::runThisTest()
|
|
|
|
{
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer = new KeypadTest();
|
2013-07-23 08:25:44 +08:00
|
|
|
addChild(layer);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene(this);
|
2013-07-23 08:25:44 +08:00
|
|
|
layer->release();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|