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();
|
|
|
|
|
|
|
|
void restartCallback(CCObject* pSender);
|
|
|
|
void nextCallback(CCObject* pSender);
|
|
|
|
void backCallback(CCObject* pSender);
|
|
|
|
|
|
|
|
std::string title();
|
|
|
|
void addKeyboardNotificationLayer(KeyboardNotificationLayer * pLayer);
|
|
|
|
|
|
|
|
virtual void onEnter();
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// KeyboardNotificationLayer for test IME keyboard notification.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class KeyboardNotificationLayer : public CCLayer, public CCIMEDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyboardNotificationLayer();
|
|
|
|
|
|
|
|
virtual std::string subtitle() = 0;
|
|
|
|
virtual void onClickTrackNode(bool bClicked) = 0;
|
|
|
|
|
|
|
|
virtual void registerWithTouchDispatcher();
|
|
|
|
virtual void keyboardWillShow(CCIMEKeyboardNotificationInfo& info);
|
|
|
|
|
|
|
|
// CCLayer
|
|
|
|
virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);
|
|
|
|
virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);
|
|
|
|
|
|
|
|
protected:
|
2013-06-15 14:03:30 +08:00
|
|
|
CCNode * _trackNode;
|
|
|
|
CCPoint _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);
|
|
|
|
|
|
|
|
// CCLayer
|
|
|
|
virtual void onEnter();
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFActionTest
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTFActionTest : public KeyboardNotificationLayer, public CCTextFieldDelegate
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCTextFieldTTF * _textField;
|
|
|
|
CCAction * _textFieldAction;
|
|
|
|
bool _action;
|
|
|
|
int _charLimit; // the textfield max char limit
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
void callbackRemoveNodeWhenDidAction(CCNode * pNode);
|
|
|
|
|
|
|
|
// KeyboardNotificationLayer
|
|
|
|
virtual std::string subtitle();
|
|
|
|
virtual void onClickTrackNode(bool bClicked);
|
|
|
|
|
|
|
|
// CCLayer
|
|
|
|
virtual void onEnter();
|
|
|
|
virtual void onExit();
|
|
|
|
|
|
|
|
// CCTextFieldDelegate
|
|
|
|
virtual bool onTextFieldAttachWithIME(CCTextFieldTTF * pSender);
|
|
|
|
virtual bool onTextFieldDetachWithIME(CCTextFieldTTF * pSender);
|
|
|
|
virtual bool onTextFieldInsertText(CCTextFieldTTF * pSender, const char * text, int nLen);
|
|
|
|
virtual bool onTextFieldDeleteBackward(CCTextFieldTTF * pSender, const char * delText, int nLen);
|
|
|
|
virtual bool onDraw(CCTextFieldTTF * pSender);
|
|
|
|
};
|
|
|
|
|
|
|
|
class TextInputTestScene : public TestScene
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void runThisTest();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __TEXT_INPUT_TEST_H__
|