PuzzleSDK
KeyboardNotificationLayer类 参考abstract

#include <TextInputTest.h>

+ 类 KeyboardNotificationLayer 继承关系图:
+ KeyboardNotificationLayer 的协作图:

Public 成员函数

 KeyboardNotificationLayer ()
 
virtual std::string title () const override
 
virtual void onClickTrackNode (bool bClicked, const cocos2d::Vec2 &touchPos)=0
 
virtual void keyboardWillShow (cocos2d::IMEKeyboardNotificationInfo &info) override
 
bool onTouchBegan (cocos2d::Touch *touch, cocos2d::Event *event)
 
void onTouchEnded (cocos2d::Touch *touch, cocos2d::Event *event)
 
- Public 成员函数 继承自 TestCase
 TestCase ()
 
 ~TestCase ()
 
virtual std::string subtitle () const
 
virtual Type getTestType () const
 
virtual float getDuration () const
 
virtual std::string getExpectedOutput () const
 
virtual std::string getActualOutput () const
 
virtual void restartTestCallback (cocos2d::Ref *sender)
 
virtual void nextTestCallback (cocos2d::Ref *sender)
 
virtual void priorTestCallback (cocos2d::Ref *sender)
 
virtual void onBackCallback (cocos2d::Ref *sender)
 
void setTestSuite (TestSuite *testSuite)
 
TestSuitegetTestSuite () const
 
float getRunTime () const
 
void setTestCaseName (const std::string &name)
 
std::string getTestCaseName () const
 
const cocos2d::Label * getSubtitleLable () const
 
const cocos2d::MenuItemImage * getRestartTestItem () const
 
virtual void onEnter () override
 

Protected 属性

cocos2d::Node * _trackNode
 
cocos2d::Vec2 _beginPos
 
- Protected 属性 继承自 TestCase
cocos2d::MenuItemImage * _priorTestItem
 
cocos2d::MenuItemImage * _restartTestItem
 
cocos2d::MenuItemImage * _nextTestItem
 
cocos2d::Label * _titleLabel
 
cocos2d::Label * _subtitleLabel
 

额外继承的成员函数

- Public 类型 继承自 TestCase
enum class  Type { ROBUSTNESS , UNIT , GRAPHICAL_STATIC , MANUAL }
 
- Public 属性 继承自 TestCase
CC_CONSTRUCTOR_ACCESS __pad0__: virtual bool init() override
 

详细描述

在文件 TextInputTest.h38 行定义.

构造及析构函数说明

◆ KeyboardNotificationLayer()

KeyboardNotificationLayer::KeyboardNotificationLayer ( )

在文件 TextInputTest.cpp59 行定义.

60: _trackNode(0)
61{
62 // Register Touch Event
63 auto listener = EventListenerTouchOneByOne::create();
64 listener->onTouchBegan = CC_CALLBACK_2(KeyboardNotificationLayer::onTouchBegan, this);
65 listener->onTouchEnded = CC_CALLBACK_2(KeyboardNotificationLayer::onTouchEnded, this);
66 _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
67}
bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event)
void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event)
cocos2d::Node * _trackNode
Definition: TextInputTest.h:51

引用了 onTouchBegan() , 以及 onTouchEnded().

+ 函数调用图:

成员函数说明

◆ keyboardWillShow()

void KeyboardNotificationLayer::keyboardWillShow ( cocos2d::IMEKeyboardNotificationInfo &  info)
overridevirtual

在文件 TextInputTest.cpp69 行定义.

70{
71 CCLOG("TextInputTest:keyboardWillShowAt(origin:%f,%f, size:%f,%f)",
72 info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height);
73
74 if (! _trackNode)
75 {
76 return;
77 }
78
79 auto rectTracked = getRect(_trackNode);
80 CCLOG("TextInputTest:trackingNodeAt(origin:%f,%f, size:%f,%f)",
81 rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height);
82
83 // if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
84 if (! rectTracked.intersectsRect(info.end))
85 {
86 return;
87 }
88
89 // assume keyboard at the bottom of screen, calculate the vertical adjustment.
90 float adjustVert = info.end.getMaxY() - rectTracked.getMinY();
91 CCLOG("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert);
92
93 // move all the children node of KeyboardNotificationLayer
94 auto& children = getChildren();
95 Node * node = 0;
96 ssize_t count = children.size();
97 Vec2 pos;
98 for (int i = 0; i < count; ++i)
99 {
100 node = children.at(i);
101 pos = node->getPosition();
102 pos.y += adjustVert;
103 node->setPosition(pos);
104 }
105}
static Rect getRect(Node *node)

引用了 _trackNode , 以及 getRect().

+ 函数调用图:

◆ onClickTrackNode()

virtual void KeyboardNotificationLayer::onClickTrackNode ( bool  bClicked,
const cocos2d::Vec2 &  touchPos 
)
pure virtual

TextFieldTTFDefaultTest, TextFieldTTFActionTest , 以及 TextFieldTTSetCursorFromPoint 内被实现.

被这些函数引用 onTouchEnded().

+ 这是这个函数的调用关系图:

◆ onTouchBegan()

bool KeyboardNotificationLayer::onTouchBegan ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 TextInputTest.cpp109 行定义.

110{
111 CCLOG("++++++++++++++++++++++++++++++++++++++++++++");
112 _beginPos = touch->getLocation();
113 return true;
114}

引用了 _beginPos.

被这些函数引用 KeyboardNotificationLayer().

+ 这是这个函数的调用关系图:

◆ onTouchEnded()

void KeyboardNotificationLayer::onTouchEnded ( cocos2d::Touch *  touch,
cocos2d::Event *  event 
)

在文件 TextInputTest.cpp116 行定义.

117{
118 if (! _trackNode)
119 {
120 return;
121 }
122
123 auto endPos = touch->getLocation();
124
125 float delta = 5.0f;
126 if (std::abs(endPos.x - _beginPos.x) > delta
127 || std::abs(endPos.y - _beginPos.y) > delta)
128 {
129 // not click
130 _beginPos.x = _beginPos.y = -1;
131 return;
132 }
133
134 // decide the trackNode is clicked.
135 Rect rect;
136 rect.size = _trackNode->getContentSize();
137 auto clicked = isScreenPointInRect(endPos, Camera::getVisitingCamera(), _trackNode->getWorldToNodeTransform(), rect, nullptr);
138 this->onClickTrackNode(clicked, endPos);
139 CCLOG("----------------------------------");
140}
virtual void onClickTrackNode(bool bClicked, const cocos2d::Vec2 &touchPos)=0

引用了 _beginPos, _trackNode , 以及 onClickTrackNode().

被这些函数引用 KeyboardNotificationLayer().

+ 函数调用图:
+ 这是这个函数的调用关系图:

◆ title()

std::string KeyboardNotificationLayer::title ( ) const
overridevirtual

重载 TestCase .

在文件 TextInputTest.cpp50 行定义.

51{
52 return "text input test";
53}

类成员变量说明

◆ _beginPos

cocos2d::Vec2 KeyboardNotificationLayer::_beginPos
protected

在文件 TextInputTest.h52 行定义.

被这些函数引用 onTouchBegan() , 以及 onTouchEnded().

◆ _trackNode


该类的文档由以下文件生成: