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();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
void restartCallback(Object* pSender);
|
|
|
|
void nextCallback(Object* pSender);
|
|
|
|
void backCallback(Object* pSender);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
std::string title();
|
2013-07-23 08:25:44 +08:00
|
|
|
void addKeyboardNotificationLayer(KeyboardNotificationLayer * layer);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
virtual void onEnter();
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
virtual std::string subtitle() = 0;
|
|
|
|
virtual void onClickTrackNode(bool bClicked) = 0;
|
|
|
|
|
|
|
|
virtual void registerWithTouchDispatcher();
|
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
|
|
|
|
virtual bool ccTouchBegan(Touch *pTouch, Event *pEvent);
|
|
|
|
virtual void ccTouchEnded(Touch *pTouch, Event *pEvent);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2013-06-20 14:17:10 +08:00
|
|
|
Node * _trackNode;
|
|
|
|
Point _beginPos;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFDefaultTest for test TextFieldTTF default behavior.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTFDefaultTest : public KeyboardNotificationLayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// KeyboardNotificationLayer
|
|
|
|
virtual std::string subtitle();
|
|
|
|
virtual void onClickTrackNode(bool bClicked);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onEnter();
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// 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
|
|
|
|
virtual std::string subtitle();
|
|
|
|
virtual void onClickTrackNode(bool bClicked);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// Layer
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
// TextFieldDelegate
|
|
|
|
virtual bool onTextFieldAttachWithIME(TextFieldTTF * pSender);
|
|
|
|
virtual bool onTextFieldDetachWithIME(TextFieldTTF * pSender);
|
|
|
|
virtual bool onTextFieldInsertText(TextFieldTTF * pSender, const char * text, int nLen);
|
|
|
|
virtual bool onTextFieldDeleteBackward(TextFieldTTF * pSender, const char * delText, int nLen);
|
|
|
|
virtual bool onDraw(TextFieldTTF * pSender);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class TextInputTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __TEXT_INPUT_TEST_H__
|