Urgent please Scrollview is not scrolling when I scroll from it's children listview

Hi, I’m working on cocos2dx 3.12 version.

I have a scrollview. I added a listview to it.
And when I drag it by listview , ScrollView does not move. It moves only when I drag it itself.

Means when I scroll using listview it is not scrolling but if I scroll from other part of scrollview it scrolls properly.
Any ideas how to fix this?

my scrollview is-

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 );

my listview is -

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

// listView->setDirection(ui::ScrollView::Direction::VERTICAL);
listView->setTouchEnabled(true);
listView->setBounceEnabled(true);
listView->setSize(Size(visibleSize.width, (visibleSize.height/4)));
listView->setDirection( ui::ScrollView::Direction::HORIZONTAL );
listView->setClippingEnabled(true);
listView->setAnchorPoint(Vec2::ZERO);
listView->setPosition(Vec2::ZERO);
listView->setPosition(Vec2(00,700+200));
listView->setSwallowTouches(true);
listView->setItemsMargin(0);
listView->setScrollBarEnabled(false);
scrollView->addChild(listView);

I added ImageView to listview

imageView = ui::ImageView::create(writablePath.c_str());
imageView->setPosition(imageView->getContentSize()/2);
imageView->setTouchEnabled(true);

listView->pushBackCustomItem(imageView );

Thanks.

You have 2 problems with your posts:

  1. using old cocos2d-x, nobody will help you in that case, always use latest version
  2. not provided any code example, again nobody will help you, because it’s not a because this is not guessing of something.

Thanks for replay. I edited my question.

Please somebody help me.

I think what you refer is as design. why would you like the layout to scroll when you try to scroll inside listview ? I dont see anyt reason to do so.

Hi thanks for your replay I have added many widgets to scroll view.
And I want to scroll hole page.

@NileshShripal did you end up figuring this one one?

1 Like

I don’t know is it still need to someone but I had similar problem.
This is happens because nested ScrollView catching touch event and don’t let it go upper.
My solution was just to create new class inherited from ui::Layout, then override touch callbacks
bool hackItem::onTouchBegan(Touch* touch, Event* unused_event)
{
verticalScroll->onTouchBegan(touch, unused_event);
horisonalScroll->onTouchBegan(touch, unused_event);
return true;
}
void hackItem::onTouchMoved(Touch* touch, Event* unused_event)
{
verticalScroll->onTouchMoved(touch, unused_event);
horisonalScroll->onTouchMoved(touch, unused_event);
}
you also need to setup pointers of yours scrollviews and put object of this new class into nested scrollview.
For me was enough just to put one this hackItem in one deep nested scrollview (I have around 10 of them) to make it work.