PuzzleSDK
TextInputTest.h
浏览该文件的文档.
1/****************************************************************************
2 Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
3
4 http://www.cocos2d-x.org
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 ****************************************************************************/
24
25#ifndef __TEXT_INPUT_TEST_H__
26#define __TEXT_INPUT_TEST_H__
27
28#include "../BaseTest.h"
29
31
32DEFINE_TEST_SUITE(TextInputTests);
33
35// KeyboardNotificationLayer for test IME keyboard notification.
37
38class KeyboardNotificationLayer : public TestCase, public cocos2d::IMEDelegate
39{
40public:
42 virtual std::string title() const override;
43 virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2& touchPos) = 0;
44
45 virtual void keyboardWillShow(cocos2d::IMEKeyboardNotificationInfo& info)override;
46
47 bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event);
48 void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event);
49
50protected:
51 cocos2d::Node* _trackNode;
52 cocos2d::Vec2 _beginPos;
53};
54
56// TextFieldTTFDefaultTest for test TextFieldTTF default behavior.
58
60{
61public:
63 // KeyboardNotificationLayer
64 virtual std::string subtitle() const override;
65 virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2& touchPos) override;
66
67 // Layer
68 virtual void onEnter() override;
69};
70
72// TextFieldTTFActionTest
74
75class TextFieldTTFActionTest : public KeyboardNotificationLayer, public cocos2d::TextFieldDelegate
76{
77 cocos2d::TextFieldTTF* _textField;
78 cocos2d::Action* _textFieldAction;
79 bool _action;
80 size_t _charLimit; // the textfield max char limit
81
82public:
84 void callbackRemoveNodeWhenDidAction(Node * node);
85
86 // KeyboardNotificationLayer
87 virtual std::string subtitle() const override;
88 virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2& touchPos) override;
89
90 // Layer
91 virtual void onEnter() override;
92 virtual void onExit() override;
93
94 // TextFieldDelegate
95 virtual bool onTextFieldAttachWithIME(cocos2d::TextFieldTTF* sender) override;
96 virtual bool onTextFieldDetachWithIME(cocos2d::TextFieldTTF* sender) override;
97 virtual bool onTextFieldInsertText(cocos2d::TextFieldTTF* sender, const char * text, size_t nLen) override;
98 virtual bool onTextFieldDeleteBackward(cocos2d::TextFieldTTF* sender, const char * delText, size_t nLen) override;
99 virtual bool onDraw(cocos2d::TextFieldTTF* sender);
100};
101
103// TextFieldTTFSecureTextEntryTest for test TextFieldTTF SecureTextEntry.
105
107{
108public:
110
111 virtual std::string subtitle() const override;
112 // Layer
113 virtual void onEnter() override;
114};
115
117// TextFieldTTSetCursorFromPoint for test TextFieldTTF setCursorFromPoint.
119
121{
122public:
124 // KeyboardNotificationLayer
125 virtual std::string subtitle() const override;
126 virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2& touchPos) override;
127
128 // Layer
129 virtual void onEnter() override;
130};
131#endif // __TEXT_INPUT_TEST_H__
DEFINE_TEST_SUITE(TextInputTests)
bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2 &touchPos)=0
void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event)
virtual void keyboardWillShow(cocos2d::IMEKeyboardNotificationInfo &info) override
virtual std::string title() const override
cocos2d::Node * _trackNode
Definition: TextInputTest.h:51
void callbackRemoveNodeWhenDidAction(Node *node)
virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2 &touchPos) override
cocos2d::TextFieldTTF * _textField
Definition: TextInputTest.h:77
virtual bool onTextFieldAttachWithIME(cocos2d::TextFieldTTF *sender) override
virtual bool onTextFieldDetachWithIME(cocos2d::TextFieldTTF *sender) override
virtual bool onTextFieldDeleteBackward(cocos2d::TextFieldTTF *sender, const char *delText, size_t nLen) override
virtual bool onTextFieldInsertText(cocos2d::TextFieldTTF *sender, const char *text, size_t nLen) override
virtual std::string subtitle() const override
virtual void onExit() override
CREATE_FUNC(TextFieldTTFActionTest)
virtual bool onDraw(cocos2d::TextFieldTTF *sender)
virtual void onEnter() override
cocos2d::Action * _textFieldAction
Definition: TextInputTest.h:78
virtual std::string subtitle() const override
virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2 &touchPos) override
virtual void onEnter() override
CREATE_FUNC(TextFieldTTFDefaultTest)
virtual std::string subtitle() const override
CREATE_FUNC(TextFieldTTFSecureTextEntryTest)
virtual void onEnter() override
virtual void onEnter() override
virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2 &touchPos) override
virtual std::string subtitle() const override
CREATE_FUNC(TextFieldTTSetCursorFromPoint)