2012-04-19 14:35:52 +08:00
|
|
|
#ifndef __TEXT_INPUT_TEST_H__
|
|
|
|
#define __TEXT_INPUT_TEST_H__
|
|
|
|
|
|
|
|
#include "../testBasic.h"
|
2013-06-12 07:30:05 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
class KeyboardNotificationLayer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
@brief TextInputTest for retain prev, reset, next, main menu buttons.
|
|
|
|
*/
|
2013-06-12 07:30:05 +08:00
|
|
|
class TextInputTest : public BaseTest
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
KeyboardNotificationLayer * _notificationLayer;
|
2012-04-19 14:35:52 +08:00
|
|
|
public:
|
|
|
|
TextInputTest();
|
|
|
|
|
2014-02-20 10:53:49 +08:00
|
|
|
void restartCallback(Ref* sender);
|
|
|
|
void nextCallback(Ref* sender);
|
|
|
|
void backCallback(Ref* sender);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string title() const;
|
2013-07-23 08:25:44 +08:00
|
|
|
void addKeyboardNotificationLayer(KeyboardNotificationLayer * layer);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// KeyboardNotificationLayer for test IME keyboard notification.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class KeyboardNotificationLayer : public Layer, public IMEDelegate
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyboardNotificationLayer();
|
|
|
|
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked) = 0;
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
virtual void keyboardWillShow(IMEKeyboardNotificationInfo& info);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2013-09-03 18:22:03 +08:00
|
|
|
bool onTouchBegan(Touch *touch, Event *event);
|
|
|
|
void onTouchEnded(Touch *touch, Event *event);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-20 14:17:10 +08:00
|
|
|
Node * _trackNode;
|
2014-04-15 18:23:40 +08:00
|
|
|
Vector2 _beginPos;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFDefaultTest for test TextFieldTTF default behavior.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTFDefaultTest : public KeyboardNotificationLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// KeyboardNotificationLayer
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFActionTest
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
class TextFieldTTFActionTest : public KeyboardNotificationLayer, public TextFieldDelegate
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
TextFieldTTF * _textField;
|
|
|
|
Action * _textFieldAction;
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _action;
|
|
|
|
int _charLimit; // the textfield max char limit
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
2013-07-23 08:25:44 +08:00
|
|
|
void callbackRemoveNodeWhenDidAction(Node * node);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
// KeyboardNotificationLayer
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2014-02-27 21:10:03 +08:00
|
|
|
virtual void onEnter() override;
|
|
|
|
virtual void onExit() override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// TextFieldDelegate
|
2013-07-26 06:53:24 +08:00
|
|
|
virtual bool onTextFieldAttachWithIME(TextFieldTTF * sender);
|
|
|
|
virtual bool onTextFieldDetachWithIME(TextFieldTTF * sender);
|
2014-03-20 16:24:55 +08:00
|
|
|
virtual bool onTextFieldInsertText(TextFieldTTF * sender, const char * text, size_t nLen) override;
|
|
|
|
virtual bool onTextFieldDeleteBackward(TextFieldTTF * sender, const char * delText, size_t nLen) override;
|
2013-07-26 06:53:24 +08:00
|
|
|
virtual bool onDraw(TextFieldTTF * sender);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class TextInputTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __TEXT_INPUT_TEST_H__
|