(Solved)Urgent please Listview touch issue

(Solved)Urgent please Listview touch issue
0.0 0

#1

Hi, I’m working with cocos2dx 3.12.

I have a scroll view in scroll view I have added a list view.

I added some imageviews to Listview. Listview is scrolling properly, but touch listener is not working.

My scrollview is as follows

scrollView = ui::ScrollView::create( );

scrollView->setDirection( ui::ScrollView::Direction::VERTICAL );
scrollView->setContentSize( Size( 480, 1124 ) );
scrollView->setInnerContainerSize( Size( 480, 1324 ) );
scrollView->setBackGroundImage( "appbg.png" );
scrollView->setBounceEnabled( true );
scrollView->setTouchEnabled(true);
scrollView->setAnchorPoint( Vec2( 0.5, 0.5 ) );
scrollView->setPosition( Vec2( visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y) );
scrollView->setScrollBarEnabled(false);
this->addChild( scrollView );

and this is listview

  offerListView= ui::ListView::create();

            // listView->setDirection(ui::ScrollView::Direction::VERTICAL);
             offerListView->setTouchEnabled(true);
             offerListView->setBounceEnabled(true);
             offerListView->setSize(Size(visibleSize.width, (visibleSize.height/4)));
             offerListView->setDirection( ui::ScrollView::Direction::HORIZONTAL );
             offerListView->setClippingEnabled(true);
             offerListView->setAnchorPoint(Vec2::ZERO);
             offerListView->setPosition(Vec2::ZERO);
             offerListView->setPosition(Vec2(00,70+200));
             offerListView->setSwallowTouches(true);
             offerListView->setItemsMargin(5);
             offerListView->setScrollBarEnabled(false);
        
            offerListView->addEventListener([&](Ref* ref,ui::ListView::EventType eventType){
            if(eventType == ui::ListView::EventType::ON_SELECTED_ITEM_END)
            {
         
                CCLog("in offerListView");
            }
            });
             scrollView->addChild(offerListView);

I added image view in listview
imageView = ui::ImageView::create(writablePath.c_str());
imageView->setPosition(imageView->getContentSize()/2);
offerListView->pushBackCustomItem(imageView);

please help me why touch is not working.
thanks.


#2

could it be you just miss
imageView->setTouchEnabled(true);
?


#3

thanks for replay.

yes you are right. problem solved.

Thank you.