Buttons make PageView not work properly

I added a PageView with about 5 pages. Each page contains several buttons. The PageView does not allow me to swipe left or right to change pages when I swipe where a button is. The button will click and the PageView does nothing. If I swipe left or right on the PageView where there are no buttons it works fine. Is there a way to make my PageView work even if I swipe where buttons are? It’s kind of pointless if it doesn’t let you change pages because all of the buttons are stealing the touch.

1 Like

Ok I figured out more about what is happening here. If I place the buttons directly as a child of a page, it works well. When you drag the page the buttons will lose their focus and the page slides like it should.

If the buttons are not directly a child of the page, but a child of a child, then the pageview completely breaks. I solved my issue by putting my buttons as a child of the page instead of having them inside a layer, and putting the layer on the page. This is a bit of an inconvenience for me but it’s a workaround.

1 Like

Can you give me more details such as code samples, please? I also got this problem. :frowning:
Thank you very much.

Please check my code.

_Banjonborno_main = CSLoader::createNode(“Banjonborno_main.csb”);

	   auto *pageView = (cocos2d::ui::PageView* )_Banjonborno_main->getChildByTag( 214 );
     // b1->addClickEventListener(pageViewPressed);
     
	
	  auto *sprite1 = (cocos2d::ui::Button* )_Banjonborno_main->getChildByTag( 17 );
	auto leftPressed = [](Ref *sender) {

   //  MessageBox("my message", "title");
 };
 
 sprite1->addClickEventListener(leftPressed);

 this->addChild(_Banjonborno_main);

Let me know why this code not working.
App Close automatically when I run it.