Home > other >  Cocos on pageview nested listview, incident response
Cocos on pageview nested listview, incident response

Time:09-23

Does the cocos warrior, I in a layer to load a pageview, then into the pageview addpage another layer, layer instead of a listview, how to deal with pageview pages, not trigger a listview events, listview drop-down slide does not trigger a pageview flip events, I was made of the lua, is there any warrior guidance, bothering me for a few days, thank you very much!

CodePudding user response:

No warrior guide? Warrior are busy???????

CodePudding user response:

Write the listview and pageview is set to prohibit touch, a touch event on the layout, the layout of touch to monitor events in judgment, in the layout of touchbegin events respectively called listview and pageview touchbegin events; In layout touchmove is more mobile than the difference between x and y, is greater than 1 in layout touchmove calls the pageview touchmove events, less than 1 when the listview touchmove; Finally in layout touchend events with touchmove call object to call touchend events, click after moving inertia processing;
Auto listener=EventListenerTouchOneByOne: : create ();
The listener - & gt; OnTouchBegan=[this layout] (Touch Touch * and Event * Event)
{
Auto touchPoint=touch - & gt; GetLocation ();
TouchPoint=this - & gt; ConvertToNodeSpace (touchPoint);
Auto box=layout - & gt; GetBoundingBox ();

If (box. ContainsPoint (touchPoint))
{
CurPage=pageView - & gt; GetCurPageIndex ();
ListView. Ats (curPage) - & gt; OnTouchBegan (touch, event);
PageView - & gt; OnTouchBegan (touch, event);

//judgment and move up and down or so pages of elastic motion is completed
Auto listViewContainerPosY=listView. Ats (curPage) - & gt; GetInnerContainerPosition (.) y;
Auto pageViewContainerPosX=pageView - & gt; GetInnerContainerPosition (). X + curPage * pageView - & gt; GetContentSize (). The width;
If (operationFlag==1 & amp; & PageViewContainerPosX!=0)
{
OperationFlag=1;
}
Else if (operationFlag==2 & amp; & ListViewContainerPosY!=0)
{
OperationFlag=2;
}
The else
{
OperationFlag=0;
}
return true;

}
return false;
};
The listener - & gt; OnTouchMoved=[this] (Touch Touch * and Event * Event)
{
Auto delta=touch - & gt; GetDelta ();
If (operationFlag==0)
{
If (abs (delta. X/delta. Y) & gt;
=1){
OperationFlag=1;
}
The else
{
OperationFlag=2;
}
}
If (operationFlag==1)
{
PageView - & gt; OnTouchMoved (touch, event);
}
Else if (operationFlag==2)
{
ListView. Ats (curPage) - & gt; OnTouchMoved (touch, event);
}
};
The listener - & gt; OnTouchEnded=[this] (Touch Touch * and Event * Event)
{
If (operationFlag==1)
{
PageView - & gt; OnTouchEnded (touch, event);
}
Else if (operationFlag==2)
{
ListView. Ats (curPage) - & gt; OnTouchEnded (touch, event);
}

};
_eventDispatcher - & gt; AddEventListenerWithSceneGraphPriority (listener, layout);
  • Related