-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Updates PR #17476 (Remove _claimedTouches Flags for listeners) #17527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3
Are you sure you want to change the base?
Conversation
Once a new touch is begin, we should clear the _claimedTouches for the one by one listeners. Since the touch begin and touch end is not always in pairs ! Image a call event->stopPropagation() in function onTouchEnded(), it will make the other listeners have no end events ! even the other listeners has begin event and the onTouchBegin fuction return true.
|
DON'T MERGE IT NOW. |
| for (auto l : (*fixedPriorityListeners)) | ||
| { | ||
| EventListenerTouchOneByOne* listener = static_cast<EventListenerTouchOneByOne*>(l); | ||
| listener->_claimedTouches.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dadidzf , if clear _claimedTouches, it may break the multi-touch logic of using EventListenerTouchOneByOne. I will check TouchTest to see whether it works after this fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that this patch breaks cpp-tests/63:Touches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dumganhar Thanks, Do you know why it breaks? I test the cpp-tests/63, it is ok ! it seems multi-touch do not use _claimedTouches
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dadidzf , just test it on iOS or Android mobile phones. Using multi-touch on the white blocks. The second time you touch the blocks, it will not be responsive.
|
@dadidzf do you have any question about this PR? If not, i will merge it. Thanks. |
|
@minggo , please don't merge this PR. |
|
@minggo This patch do cause some issues as @dumganhar described , it can not be merged! we need to find a different way to fix it ! ^_^ |
|
Got it, thanks. |
PR #17476
Uses range loop for clearing claimed touches in the next touch begin event.
Image We have two sprite squares, A (Left) and square B(Right), A is above of B, Both A and B have one by one touch listeners, and it will not swallow touches.
Click at the intersection of A and B, do not move
Touch press
A - onTouchBegan, return true, listener->_claimedTouches is true for A
B - onTouchBegan, return true, listener->_claimedTouches is true for B
Touch release
A - onTouchEnded, we manually call event->stopPropagation() in the onTouchEnd function !!! listener->_claimedTouches is cleared
B - Because A stopPropagation, listener->_claimedTouches is not cleared
In this case, Because A stop propagation for touch end, the listener->_claimedTouches for B will not be cleared forever ! because B has touch begin, which record the touch in listener->_claimedTouches, but it has not touch end !