mirror of https://github.com/axmolengine/axmol.git
fix addEventListener hidden problem
This commit is contained in:
parent
b65991bf85
commit
c9bcbfb265
|
@ -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;
|
||||
|
|
|
@ -174,6 +174,7 @@ 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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#define __TestCpp__UIListViewTest__
|
||||
|
||||
#include "../UIScene.h"
|
||||
#include "ui/UIScrollView.h"
|
||||
|
||||
class UIListViewTest_Vertical : public UIScene
|
||||
{
|
||||
|
@ -34,6 +35,7 @@ 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)
|
||||
|
@ -50,6 +52,7 @@ public:
|
|||
bool init();
|
||||
void selectedItemEvent(Ref* pSender, ListView::EventType type);
|
||||
|
||||
|
||||
protected:
|
||||
UI_SCENE_CREATE_FUNC(UIListViewTest_Horizontal)
|
||||
Text* _displayValueLabel;
|
||||
|
|
Loading…
Reference in New Issue