2012-04-19 14:35:52 +08:00
|
|
|
#ifndef __TEXT_INPUT_TEST_H__
|
|
|
|
#define __TEXT_INPUT_TEST_H__
|
|
|
|
|
2013-06-12 07:30:05 +08:00
|
|
|
#include "../BaseTest.h"
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
class KeyboardNotificationLayer;
|
|
|
|
|
2015-04-03 14:31:03 +08:00
|
|
|
DEFINE_TEST_SUITE(TextInputTests);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// KeyboardNotificationLayer for test IME keyboard notification.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-04-09 12:23:47 +08:00
|
|
|
class KeyboardNotificationLayer : public TestCase, public cocos2d::IMEDelegate
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
KeyboardNotificationLayer();
|
2015-04-03 14:31:03 +08:00
|
|
|
virtual std::string title() const override;
|
2012-04-19 14:35:52 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked) = 0;
|
|
|
|
|
2015-04-09 12:23:47 +08:00
|
|
|
virtual void keyboardWillShow(cocos2d::IMEKeyboardNotificationInfo& info);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2015-04-09 08:37:30 +08:00
|
|
|
bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
|
|
|
|
void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event);
|
2012-04-19 14:35:52 +08:00
|
|
|
|
|
|
|
protected:
|
2015-04-09 08:37:30 +08:00
|
|
|
cocos2d::Node* _trackNode;
|
|
|
|
cocos2d::Vec2 _beginPos;
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TextFieldTTFDefaultTest for test TextFieldTTF default behavior.
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TextFieldTTFDefaultTest : public KeyboardNotificationLayer
|
|
|
|
{
|
|
|
|
public:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(TextFieldTTFDefaultTest);
|
2012-04-19 14:35:52 +08:00
|
|
|
// KeyboardNotificationLayer
|
2013-12-19 05:52:10 +08:00
|
|
|
virtual std::string subtitle() const override;
|
2015-03-15 07:10:08 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
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
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-04-09 12:23:47 +08:00
|
|
|
class TextFieldTTFActionTest : public KeyboardNotificationLayer, public cocos2d::TextFieldDelegate
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2015-04-09 12:23:47 +08:00
|
|
|
cocos2d::TextFieldTTF* _textField;
|
|
|
|
cocos2d::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:
|
2015-04-03 14:31:03 +08:00
|
|
|
CREATE_FUNC(TextFieldTTFActionTest);
|
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;
|
2015-03-15 07:10:08 +08:00
|
|
|
virtual void onClickTrackNode(bool bClicked) override;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
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
|
2015-04-09 12:23:47 +08:00
|
|
|
virtual bool onTextFieldAttachWithIME(cocos2d::TextFieldTTF* sender) override;
|
|
|
|
virtual bool onTextFieldDetachWithIME(cocos2d::TextFieldTTF* sender) override;
|
|
|
|
virtual bool onTextFieldInsertText(cocos2d::TextFieldTTF* sender, const char * text, size_t nLen) override;
|
|
|
|
virtual bool onTextFieldDeleteBackward(cocos2d::TextFieldTTF* sender, const char * delText, size_t nLen) override;
|
|
|
|
virtual bool onDraw(cocos2d::TextFieldTTF* sender);
|
2012-04-19 14:35:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // __TEXT_INPUT_TEST_H__
|