fix addEventListener hidden problem

This commit is contained in:
andyque 2014-06-23 12:09:49 +08:00
parent b65991bf85
commit c9bcbfb265
5 changed files with 30 additions and 3 deletions

View File

@ -454,6 +454,12 @@ void ListView::addEventListenerListView(Ref *target, SEL_ListViewEvent selector)
_listViewEventSelector = selector;
}
void ListView::addEventListener(const ccScrollViewCallback& callback)
{
ScrollView::addEventListener(callback);
}
void ListView::addEventListener(const ccListViewCallback& callback)
{
_eventCallback = callback;

View File

@ -174,7 +174,8 @@ public:
CC_DEPRECATED_ATTRIBUTE void addEventListenerListView(Ref* target, SEL_ListViewEvent selector);
void addEventListener(const ccListViewCallback& callback);
virtual void addEventListener(const ccScrollViewCallback& callback) override;
/**
* Changes scroll direction of scrollview.
*

View File

@ -251,7 +251,7 @@ public:
* Add call back function called scrollview event triggered
*/
CC_DEPRECATED_ATTRIBUTE void addEventListenerScrollView(Ref* target, SEL_ScrollViewEvent selector);
void addEventListener(const ccScrollViewCallback& callback);
virtual void addEventListener(const ccScrollViewCallback& callback);
//all of these functions are related to innerContainer.
virtual void addChild(Node * child) override;

View File

@ -66,6 +66,8 @@ bool UIListViewTest_Vertical::init()
(widgetSize.height - backgroundSize.height) / 2.0f +
(backgroundSize.height - listView->getSize().height) / 2.0f));
listView->addEventListener(CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEvent, this));
listView->addEventListener(CC_CALLBACK_2(UIListViewTest_Vertical::selectedItemEventScrollView,this));
_uiLayer->addChild(listView);
@ -187,6 +189,21 @@ void UIListViewTest_Vertical::selectedItemEvent(Ref *pSender, ListView::EventTyp
}
}
void UIListViewTest_Vertical::selectedItemEventScrollView(Ref* pSender, ui::ScrollView::EventType type)
{
switch (type) {
case ui::ScrollView::EventType::SCROLL_TO_BOTTOM:
CCLOG("SCROLL_TO_BOTTOM");
break;
case ui::ScrollView::EventType::SCROLL_TO_TOP:
CCLOG("SCROLL_TO_TOP");
break;
default:
break;
}
}
// UIListViewTest_Horizontal
UIListViewTest_Horizontal::UIListViewTest_Horizontal()

View File

@ -26,6 +26,7 @@
#define __TestCpp__UIListViewTest__
#include "../UIScene.h"
#include "ui/UIScrollView.h"
class UIListViewTest_Vertical : public UIScene
{
@ -34,7 +35,8 @@ public:
~UIListViewTest_Vertical();
bool init();
void selectedItemEvent(Ref* pSender, ListView::EventType type);
void selectedItemEventScrollView(Ref* pSender, ui::ScrollView::EventType type);
protected:
UI_SCENE_CREATE_FUNC(UIListViewTest_Vertical)
Text* _displayValueLabel;
@ -49,6 +51,7 @@ public:
~UIListViewTest_Horizontal();
bool init();
void selectedItemEvent(Ref* pSender, ListView::EventType type);
protected:
UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal)