issue #5057, refactor addTouchEventListener to std::function<>

This commit is contained in:
andyque 2014-05-09 14:30:39 +08:00
parent 7d1cb7af47
commit 57ce0ee2cf
28 changed files with 163 additions and 149 deletions

View File

@ -39,6 +39,7 @@ CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_ABSOLUTE = Widget::SizeType:
CC_DEPRECATED_ATTRIBUTE const Widget::SizeType SIZE_PERCENT = Widget::SizeType::PERCENT;
}

View File

@ -399,16 +399,17 @@ cocos2d::Node* UIComponentTest::createGameScene()
ComRender *render = static_cast<ComRender*>(_node->getChildByTag(10025)->getComponent("GUIComponent"));
Widget* widget = static_cast<cocos2d::ui::Widget*>(render->getNode());
Button* button = static_cast<Button*>(widget->getChildByName("Button_156"));
button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIComponentTest::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIComponentTest::touchEvent, this));
return node;
}
void UIComponentTest::touchEvent(Ref *pSender, TouchEventType type)
void UIComponentTest::touchEvent(Ref *pSender, ui::Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_BEGAN:
case ui::Widget::TouchEventType::BEGAN:
{
ComRender *pBlowFish = static_cast<ComRender*>(_node->getChildByTag(10010)->getComponent("CCArmature"));
pBlowFish->getNode()->runAction(CCMoveBy::create(10.0f, Vector2(-1000.0f, 0)));

View File

@ -100,7 +100,7 @@ public:
virtual void onEnter() override;
virtual void onExit() override;
cocos2d::Node* createGameScene();
void touchEvent(cocos2d::Ref *pSender, cocos2d::ui::TouchEventType type);
void touchEvent(cocos2d::Ref *pSender, ui::Widget::TouchEventType type);
private:
cocos2d::Node* _node;
};

View File

@ -19,7 +19,7 @@ public:
void onTouchesBegan(const std::vector<Touch*>& touches, Event *event);
// void onTouchesMoved(const std::vector<Touch*>& touches, Event *event);
void touchEvent(Ref* pSender, TouchEventType type);
void touchEvent(Ref* pSender, Widget::TouchEventType type);
private:
Vector2 _beginPos;

View File

@ -39,7 +39,8 @@ bool UIButtonTest::init()
Button* button = Button::create("cocosui/animationbuttonnormal.png",
"cocosui/animationbuttonpressed.png");
button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIButtonTest::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest::touchEvent, this));
_uiLayer->addChild(button);
return true;
@ -47,23 +48,23 @@ bool UIButtonTest::init()
return false;
}
void UIButtonTest::touchEvent(Ref *pSender, TouchEventType type)
void UIButtonTest::touchEvent(Ref *pSender, Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_BEGAN:
case Widget::TouchEventType::BEGAN:
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
break;
case TOUCH_EVENT_MOVED:
case Widget::TouchEventType::MOVED:
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
break;
case TOUCH_EVENT_ENDED:
case Widget::TouchEventType::ENDED:
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
break;
case TOUCH_EVENT_CANCELED:
case Widget::TouchEventType::CANCELED:
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
break;
@ -110,7 +111,8 @@ bool UIButtonTest_Scale9::init()
button->setScale9Enabled(true);
button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
button->setSize(Size(150, 70));
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Scale9::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Scale9::touchEvent, this));
_uiLayer->addChild(button);
return true;
@ -118,23 +120,23 @@ bool UIButtonTest_Scale9::init()
return false;
}
void UIButtonTest_Scale9::touchEvent(Ref *pSender, TouchEventType type)
void UIButtonTest_Scale9::touchEvent(Ref *pSender, Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_BEGAN:
case Widget::TouchEventType::BEGAN:
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
break;
case TOUCH_EVENT_MOVED:
case Widget::TouchEventType::MOVED:
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
break;
case TOUCH_EVENT_ENDED:
case Widget::TouchEventType::ENDED:
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
break;
case TOUCH_EVENT_CANCELED:
case Widget::TouchEventType::CANCELED:
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
break;
@ -178,7 +180,8 @@ bool UIButtonTest_PressedAction::init()
Button* button = Button::create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png");
button->setPressedActionEnabled(true);
button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIButtonTest_PressedAction::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_PressedAction::touchEvent, this));
_uiLayer->addChild(button);
return true;
@ -186,23 +189,23 @@ bool UIButtonTest_PressedAction::init()
return false;
}
void UIButtonTest_PressedAction::touchEvent(Ref *pSender, TouchEventType type)
void UIButtonTest_PressedAction::touchEvent(Ref *pSender, Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_BEGAN:
case Widget::TouchEventType::BEGAN:
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
break;
case TOUCH_EVENT_MOVED:
case Widget::TouchEventType::MOVED:
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
break;
case TOUCH_EVENT_ENDED:
case Widget::TouchEventType::ENDED:
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
break;
case TOUCH_EVENT_CANCELED:
case Widget::TouchEventType::CANCELED:
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
break;
@ -246,7 +249,8 @@ bool UIButtonTest_Title::init()
Button* button = Button::create("cocosui/backtotoppressed.png", "cocosui/backtotopnormal.png");
button->setTitleText("Title Button");
button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f));
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Title::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Title::touchEvent, this));
_uiLayer->addChild(button);
return true;
@ -255,23 +259,23 @@ bool UIButtonTest_Title::init()
}
void UIButtonTest_Title::touchEvent(Ref *pSender, TouchEventType type)
void UIButtonTest_Title::touchEvent(Ref *pSender, Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_BEGAN:
case Widget::TouchEventType::BEGAN:
_displayValueLabel->setText(String::createWithFormat("Touch Down")->getCString());
break;
case TOUCH_EVENT_MOVED:
case Widget::TouchEventType::MOVED:
_displayValueLabel->setText(String::createWithFormat("Touch Move")->getCString());
break;
case TOUCH_EVENT_ENDED:
case Widget::TouchEventType::ENDED:
_displayValueLabel->setText(String::createWithFormat("Touch Up")->getCString());
break;
case TOUCH_EVENT_CANCELED:
case Widget::TouchEventType::CANCELED:
_displayValueLabel->setText(String::createWithFormat("Touch Cancelled")->getCString());
break;

View File

@ -33,7 +33,7 @@ public:
UIButtonTest();
~UIButtonTest();
bool init();
void touchEvent(Ref *pSender, TouchEventType type);
void touchEvent(Ref *pSender, Widget::TouchEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIButtonTest)
@ -46,7 +46,7 @@ public:
UIButtonTest_Scale9();
~UIButtonTest_Scale9();
bool init();
void touchEvent(Ref *pSender, TouchEventType type);
void touchEvent(Ref *pSender, Widget::TouchEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIButtonTest_Scale9)
@ -59,7 +59,7 @@ public:
UIButtonTest_PressedAction();
~UIButtonTest_PressedAction();
bool init();
void touchEvent(Ref *pSender, TouchEventType type);
void touchEvent(Ref *pSender, Widget::TouchEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIButtonTest_PressedAction)
@ -72,7 +72,7 @@ public:
UIButtonTest_Title();
~UIButtonTest_Title();
bool init();
void touchEvent(Ref *pSender, TouchEventType type);
void touchEvent(Ref *pSender, Widget::TouchEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIButtonTest_Title)

View File

@ -30,18 +30,22 @@ bool UIButtonTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
Button* button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_123"));
button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
Button* title_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_126"));
title_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent));
// title_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent));
title_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
Button* scale9_button = static_cast<Button*>(Helper::seekWidgetByName(root, "Button_129"));
scale9_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent));
// scale9_button->addTouchEventListener(this, toucheventselector(UIButtonTest_Editor::touchEvent));
scale9_button->addTouchEventListener(CC_CALLBACK_2(UIButtonTest_Editor::touchEvent, this));
_displayValueLabel = Text::create();
_displayValueLabel->setFontName("fonts/Marker Felt.ttf");
@ -57,23 +61,23 @@ bool UIButtonTest_Editor::init()
return false;
}
void UIButtonTest_Editor::touchEvent(Ref *pSender, TouchEventType type)
void UIButtonTest_Editor::touchEvent(Ref *pSender, Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_BEGAN:
case Widget::TouchEventType::BEGAN:
_displayValueLabel->setText("Touch Down");
break;
case TOUCH_EVENT_MOVED:
case Widget::TouchEventType::MOVED:
_displayValueLabel->setText("Touch Moved");
break;
case TOUCH_EVENT_ENDED:
case Widget::TouchEventType::ENDED:
_displayValueLabel->setText("Touch Ended");
break;
case TOUCH_EVENT_CANCELED:
case Widget::TouchEventType::CANCELED:
_displayValueLabel->setText("Touch Canceled");
break;

View File

@ -34,7 +34,7 @@ public:
~UIButtonTest_Editor();
bool init();
void touchEvent(Ref* pSender, TouchEventType type);
void touchEvent(Ref* pSender, Widget::TouchEventType type);
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UIButtonTest_Editor);

View File

@ -30,7 +30,7 @@ bool UICheckBoxTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -60,9 +60,9 @@ bool UIFocusTestBase::init()
return false;
}
void UIFocusTestBase::onImageViewClicked(cocos2d::Ref *ref, TouchEventType touchType)
void UIFocusTestBase::onImageViewClicked(cocos2d::Ref *ref, Widget::TouchEventType touchType)
{
if (touchType == TouchEventType::TOUCH_EVENT_ENDED) {
if (touchType == Widget::TouchEventType::ENDED) {
Widget *w = (Widget*)ref;
if (w->isFocusEnabled()) {
w->setFocusEnabled(false);
@ -166,7 +166,7 @@ bool UIFocusTestHorizontal::init()
ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
w->setTouchEnabled(true);
w->setTag(i);
w->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestHorizontal::onImageViewClicked, this));
_horizontalLayout->addChild(w);
}
@ -179,7 +179,7 @@ bool UIFocusTestHorizontal::init()
btn->setTitleText("Toggle Loop");
btn->setPosition(Vector2(60, winSize.height - 50));
btn->setTitleColor(Color3B::RED);
btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop));
btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestHorizontal::toggleFocusLoop,this));
this->addChild(btn);
@ -191,9 +191,9 @@ bool UIFocusTestHorizontal::init()
void UIFocusTestHorizontal::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type)
void UIFocusTestHorizontal::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type)
{
if (type == TouchEventType::TOUCH_EVENT_ENDED) {
if (type == Widget::TouchEventType::ENDED) {
_horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus());
if (_horizontalLayout->isLoopFocus()) {
_loopText->setText("loop enabled");
@ -236,7 +236,7 @@ bool UIFocusTestVertical::init()
ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
w->setTouchEnabled(true);
w->setTag(i);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestVertical::onImageViewClicked, this));
_verticalLayout->addChild(w);
if (i == 2) {
w->requestFocus();
@ -252,7 +252,7 @@ bool UIFocusTestVertical::init()
btn->setTitleText("Toggle Loop");
btn->setPosition(Vector2(60, winSize.height - 50));
btn->setTitleColor(Color3B::RED);
btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop));
btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestVertical::toggleFocusLoop, this));
this->addChild(btn);
@ -262,9 +262,9 @@ bool UIFocusTestVertical::init()
}
void UIFocusTestVertical::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type)
void UIFocusTestVertical::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type)
{
if (type == TouchEventType::TOUCH_EVENT_ENDED) {
if (type == Widget::TouchEventType::ENDED) {
_verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
if (_verticalLayout->isLoopFocus()) {
_loopText->setText("loop enabled");
@ -308,7 +308,7 @@ bool UIFocusTestNestedLayout1::init()
w->setTouchEnabled(true);
w->setScaleX(2.5);
w->setTag(i+count1);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this));
_verticalLayout->addChild(w);
}
@ -325,7 +325,7 @@ bool UIFocusTestNestedLayout1::init()
w->setScaleY(2.0);
w->setTouchEnabled(true);
w->setTag(i+count1+count2);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this));
hbox->addChild(w);
}
@ -341,7 +341,7 @@ bool UIFocusTestNestedLayout1::init()
ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
w->setTouchEnabled(true);
w->setTag(i+count1+count2+count3);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::onImageViewClicked, this));
innerVBox->addChild(w);
}
@ -354,7 +354,7 @@ bool UIFocusTestNestedLayout1::init()
btn->setTitleText("Toggle Loop");
btn->setPosition(Vector2(60, winSize.height - 50));
btn->setTitleColor(Color3B::RED);
btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop));
btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout1::toggleFocusLoop, this));
this->addChild(btn);
@ -364,9 +364,9 @@ bool UIFocusTestNestedLayout1::init()
}
void UIFocusTestNestedLayout1::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type)
void UIFocusTestNestedLayout1::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type)
{
if (type == TouchEventType::TOUCH_EVENT_ENDED) {
if (type == Widget::TouchEventType::ENDED) {
_verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
if (_verticalLayout->isLoopFocus()) {
_loopText->setText("loop enabled");
@ -410,7 +410,7 @@ bool UIFocusTestNestedLayout2::init()
w->setTouchEnabled(true);
w->setTag(i+count1);
w->setScaleY(2.4);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this));
_horizontalLayout->addChild(w);
}
@ -427,7 +427,7 @@ bool UIFocusTestNestedLayout2::init()
w->setScaleX(2.0);
w->setTouchEnabled(true);
w->setTag(i+count1+count2);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this));
vbox->addChild(w);
}
@ -443,7 +443,7 @@ bool UIFocusTestNestedLayout2::init()
ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
w->setTouchEnabled(true);
w->setTag(i+count1+count2+count3);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::onImageViewClicked, this));
innerHBox->addChild(w);
}
@ -456,7 +456,7 @@ bool UIFocusTestNestedLayout2::init()
btn->setTitleText("Toggle Loop");
btn->setPosition(Vector2(60, winSize.height - 50));
btn->setTitleColor(Color3B::RED);
btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop));
btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout2::toggleFocusLoop, this));
this->addChild(btn);
@ -466,9 +466,9 @@ bool UIFocusTestNestedLayout2::init()
}
void UIFocusTestNestedLayout2::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type)
void UIFocusTestNestedLayout2::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type)
{
if (type == TouchEventType::TOUCH_EVENT_ENDED) {
if (type == Widget::TouchEventType::ENDED) {
_horizontalLayout->setLoopFocus(!_horizontalLayout->isLoopFocus());
if (_horizontalLayout->isLoopFocus()) {
_loopText->setText("loop enabled");
@ -529,7 +529,7 @@ bool UIFocusTestNestedLayout3::init()
ImageView *w = ImageView::create("cocosui/scrollviewbg.png");
w->setTouchEnabled(true);
w->setTag(j+firstVbox->getTag()+1);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestBase::onImageViewClicked, this));
firstVbox->addChild(w);
}
@ -550,7 +550,7 @@ bool UIFocusTestNestedLayout3::init()
w->setLayoutParameter(bottomParams);
w->setTouchEnabled(true);
w->setTag(i+601);
w->addTouchEventListener(this, toucheventselector(UIFocusTestVertical::onImageViewClicked));
w->addTouchEventListener(CC_CALLBACK_2(UIFocusTestBase::onImageViewClicked, this));
bottomHBox->addChild(w);
}
_verticalLayout->addChild(bottomHBox);
@ -566,7 +566,7 @@ bool UIFocusTestNestedLayout3::init()
btn->setTitleText("Toggle Loop");
btn->setPosition(Vector2(60, winSize.height - 50));
btn->setTitleColor(Color3B::RED);
btn->addTouchEventListener(this, toucheventselector(UIFocusTestHorizontal::toggleFocusLoop));
btn->addTouchEventListener(CC_CALLBACK_2(UIFocusTestNestedLayout3::toggleFocusLoop, this));
this->addChild(btn);
@ -576,9 +576,9 @@ bool UIFocusTestNestedLayout3::init()
}
void UIFocusTestNestedLayout3::toggleFocusLoop(cocos2d::Ref * pObjc, TouchEventType type)
void UIFocusTestNestedLayout3::toggleFocusLoop(cocos2d::Ref * pObjc, Widget::TouchEventType type)
{
if (type == TouchEventType::TOUCH_EVENT_ENDED) {
if (type == Widget::TouchEventType::ENDED) {
_verticalLayout->setLoopFocus(!_verticalLayout->isLoopFocus());
if (_verticalLayout->isLoopFocus()) {
_loopText->setText("loop enabled");

View File

@ -26,7 +26,7 @@ public:
virtual void onDownKeyPressed();
virtual void onFocusChanged(Widget* widgetLostFocus, Widget* widgetGetFocus);
void onImageViewClicked(Ref* ref, TouchEventType touchType);
void onImageViewClicked(Ref* ref, Widget::TouchEventType touchType);
protected:
Menu *_dpadMenu;
@ -42,7 +42,7 @@ public:
bool init();
void toggleFocusLoop(Ref*,TouchEventType);
void toggleFocusLoop(Ref*,Widget::TouchEventType);
protected:
UI_SCENE_CREATE_FUNC(UIFocusTestHorizontal);
@ -58,7 +58,7 @@ public:
bool init();
void toggleFocusLoop(Ref*,TouchEventType);
void toggleFocusLoop(Ref*,Widget::TouchEventType);
protected:
UI_SCENE_CREATE_FUNC(UIFocusTestVertical);
Layout *_verticalLayout;
@ -73,7 +73,7 @@ public:
bool init();
void toggleFocusLoop(Ref*,TouchEventType);
void toggleFocusLoop(Ref*,Widget::TouchEventType);
protected:
UI_SCENE_CREATE_FUNC(UIFocusTestNestedLayout1);
Layout *_verticalLayout;
@ -88,7 +88,7 @@ public:
bool init();
void toggleFocusLoop(Ref*,TouchEventType);
void toggleFocusLoop(Ref*,Widget::TouchEventType);
protected:
UI_SCENE_CREATE_FUNC(UIFocusTestNestedLayout2);
Layout *_horizontalLayout;
@ -103,7 +103,7 @@ public:
bool init();
void toggleFocusLoop(Ref*,TouchEventType);
void toggleFocusLoop(Ref*,Widget::TouchEventType);
protected:
UI_SCENE_CREATE_FUNC(UIFocusTestNestedLayout3);
Layout *_verticalLayout;

View File

@ -19,7 +19,7 @@ bool UIImageViewTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -29,7 +29,7 @@ bool UILayoutTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -38,7 +38,7 @@ bool UILayoutTest_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -48,7 +48,7 @@ bool UILayoutTest_Editor::init()
right_button->getSize().height));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -84,7 +84,7 @@ bool UILayoutTest_Color_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -93,7 +93,7 @@ bool UILayoutTest_Color_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -103,7 +103,7 @@ bool UILayoutTest_Color_Editor::init()
right_button->getSize().height));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -139,7 +139,7 @@ bool UILayoutTest_Gradient_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -148,7 +148,7 @@ bool UILayoutTest_Gradient_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -158,7 +158,7 @@ bool UILayoutTest_Gradient_Editor::init()
right_button->getSize().height));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -194,7 +194,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -203,7 +203,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -213,7 +213,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -249,7 +249,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -258,7 +258,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -268,7 +268,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
right_button->getSize().height));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -304,7 +304,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -313,7 +313,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -323,7 +323,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -359,7 +359,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -368,7 +368,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -378,7 +378,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
@ -415,7 +415,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -424,7 +424,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -434,7 +434,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -470,7 +470,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -479,7 +479,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -489,7 +489,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;

View File

@ -29,7 +29,7 @@ bool UIListViewTest_Vertical_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -41,7 +41,9 @@ bool UIListViewTest_Vertical_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -51,7 +53,7 @@ bool UIListViewTest_Vertical_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback,this));
_layout->addChild(right_button);
return true;
@ -88,7 +90,7 @@ bool UIListViewTest_Horizontal_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene,this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -97,7 +99,7 @@ bool UIListViewTest_Horizontal_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback,this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -107,7 +109,7 @@ bool UIListViewTest_Horizontal_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
}

View File

@ -31,7 +31,8 @@ bool UILoadingBarTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
// back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -64,7 +65,7 @@ void UILoadingBarTest_Editor::update(float delta)
loadingBar_right_to_left->setPercent(_count);
}
void UILoadingBarTest_Editor::toCocosGUITestScene(Widget::TouchEventType event)
void UILoadingBarTest_Editor::toCocosGUITestScene(Ref* sender, Widget::TouchEventType event)
{
switch (event)
{
@ -72,7 +73,7 @@ void UILoadingBarTest_Editor::toCocosGUITestScene(Widget::TouchEventType event)
{
unscheduleUpdate();
UIScene_Editor::toGUIEditorTestScene(event);
UIScene_Editor::toGUIEditorTestScene(sender, event);
}
break;

View File

@ -12,7 +12,7 @@ public:
~UILoadingBarTest_Editor();
bool init();
void update(float delta);
void toCocosGUITestScene(Widget::TouchEventType event);
void toCocosGUITestScene(Ref* sender, Widget::TouchEventType event);
protected:
UI_SCENE_EDITOR_CREATE_FUNC(UILoadingBarTest_Editor)

View File

@ -30,7 +30,7 @@ bool UIPageViewTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -39,7 +39,7 @@ bool UIPageViewTest_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -49,7 +49,7 @@ bool UIPageViewTest_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;

View File

@ -31,7 +31,8 @@ bool UIRichTextTest::init()
button->setTouchEnabled(true);
button->setTitleText("switch");
button->setPosition(Vector2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5));
button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent));
// button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent));
button->addTouchEventListener(CC_CALLBACK_2(UIRichTextTest::touchEvent, this));
button->setLocalZOrder(10);
_widget->addChild(button);
@ -75,11 +76,11 @@ bool UIRichTextTest::init()
return false;
}
void UIRichTextTest::touchEvent(Ref *pSender, TouchEventType type)
void UIRichTextTest::touchEvent(Ref *pSender, Widget::TouchEventType type)
{
switch (type)
{
case TOUCH_EVENT_ENDED:
case Widget::TouchEventType::ENDED:
{
if (_richText->isIgnoreContentAdaptWithSize())
{

View File

@ -11,7 +11,7 @@ public:
UIRichTextTest();
~UIRichTextTest();
bool init();
void touchEvent(Ref *pSender, TouchEventType type);
void touchEvent(Ref *pSender, Widget::TouchEventType type);
protected:
UI_SCENE_CREATE_FUNC(UIRichTextTest)

View File

@ -32,7 +32,7 @@ bool UIScene_Editor::init()
return false;
}
void UIScene_Editor::previousCallback(Widget::TouchEventType event)
void UIScene_Editor::previousCallback(Ref* sender, Widget::TouchEventType event)
{
switch (event)
{
@ -45,7 +45,7 @@ void UIScene_Editor::previousCallback(Widget::TouchEventType event)
}
}
void UIScene_Editor::nextCallback(Widget::TouchEventType event)
void UIScene_Editor::nextCallback(Ref* sender, Widget::TouchEventType event)
{
switch (event)
{
@ -58,7 +58,7 @@ void UIScene_Editor::nextCallback(Widget::TouchEventType event)
}
}
void UIScene_Editor::toGUIEditorTestScene(Widget::TouchEventType event)
void UIScene_Editor::toGUIEditorTestScene(Ref* sender, Widget::TouchEventType event)
{
switch (event)
{

View File

@ -60,10 +60,10 @@ public:
~UIScene_Editor();
bool init();
virtual void previousCallback(Widget::TouchEventType event);
virtual void nextCallback(Widget::TouchEventType event);
virtual void previousCallback(Ref* sender, Widget::TouchEventType event);
virtual void nextCallback(Ref* sender, Widget::TouchEventType event);
void toGUIEditorTestScene(Widget::TouchEventType event);
void toGUIEditorTestScene(Ref* sender, Widget::TouchEventType event);
/** Title label of the scene.*/
CC_SYNTHESIZE_READONLY(Text*, _sceneTitle, SceneTitle)

View File

@ -29,7 +29,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -38,7 +38,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -48,7 +48,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -84,7 +84,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -93,7 +93,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -103,7 +103,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -139,7 +139,7 @@ bool UIScrollViewTest_Both_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
@ -148,7 +148,7 @@ bool UIScrollViewTest_Both_Editor::init()
left_button->setPosition(Vector2(_layout->getSize().width / 2 - left_button->getSize().width,
left_button->getSize().height * 0.625));
left_button->setTouchEnabled(true);
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
_layout->addChild(left_button);
@ -158,7 +158,7 @@ bool UIScrollViewTest_Both_Editor::init()
right_button->getSize().height * 0.625));
right_button->setTouchEnabled(true);
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
_layout->addChild(right_button);
return true;
@ -194,18 +194,18 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
Button* left_button = static_cast<Button*>(Helper::seekWidgetByName(root, "left_Button"));
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
Button* middle_button = static_cast<Button*>(Helper::seekWidgetByName(root, "middle_Button"));
middle_button->setVisible(false);
Button* right_button = static_cast<Button*>(Helper::seekWidgetByName(root, "right_Button"));
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
return true;
}
@ -240,18 +240,18 @@ bool UIScrollViewTest_ScrollToPercentBothDirection_Bounce_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));
Button* left_button = static_cast<Button*>(Helper::seekWidgetByName(root, "left_Button"));
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
left_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::previousCallback, this));
Button* middle_button = static_cast<Button*>(Helper::seekWidgetByName(root, "middle_Button"));
middle_button->setVisible(false);
Button* right_button = static_cast<Button*>(Helper::seekWidgetByName(root, "right_Button"));
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
right_button->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::nextCallback, this));
return true;
}

View File

@ -30,7 +30,7 @@ bool UISliderTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -18,7 +18,7 @@ bool UITextAtlasTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -19,7 +19,7 @@ bool UITextBMFontTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -30,7 +30,7 @@ bool UITextFieldTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -21,7 +21,7 @@ bool UITextTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));

View File

@ -29,7 +29,7 @@ bool UIWidgetAddNodeTest_Editor::init()
Layout* root = static_cast<Layout*>(_layout->getChildByName("root_Panel"));
Text* back_label = static_cast<Text*>(Helper::seekWidgetByName(root, "back"));
back_label->addTouchEventListener(this, toucheventselector(UIScene_Editor::toGUIEditorTestScene));
back_label->addTouchEventListener(CC_CALLBACK_2(UIScene_Editor::toGUIEditorTestScene, this));
_sceneTitle = static_cast<Text*>(Helper::seekWidgetByName(root, "UItest"));