cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

Only forward touch events if CCResponder has user interaction enabled

Open Ben-G opened this issue 10 years ago • 2 comments

With the current implementation touch events caused by an active touch will be forwarded to a CCResponder even if the responder sets userInteractionEnabled to NO.

Can be reproduced with the following sequence:

  • Start touch
  • Set userInteractionEnabledto NO
  • Move touch

With the current implementation touchMoved would be called in the above example. With the suggested change a touch event will only be forwarded if a node has userInteractionEnabled set to YES.

Ben-G avatar Jul 11 '14 04:07 Ben-G

I think, that if the user disables touch handling while a touch is ongoing, there are two options

  1. complete the touch, as the user has already accepted it (current functionality)
  2. forcefully cancel touch I don’t think just stopping to respond to an ongoing touch, is the right way.

On 11 Jul 2014, at 06:40, Benjamin Encz [email protected] wrote:

With the current implementation touch events caused by an active touch will be forwarded to a CCResponder even if the responder sets userInteractionEnabled to NO.

Can be reproduced with the following sequence:

Start touch Set userInteractionEnabledto NO Move touch With the current implementation touchMoved would be called in the above example. With the suggested change a touch event will only be forwarded if a node has userInteractionEnabled set to YES.

You can merge this Pull Request by running

git pull https://github.com/Ben-G/cocos2d-iphone respondermanager_cancel_touch Or view, comment on, or merge it at:

https://github.com/cocos2d/cocos2d-iphone/pull/882

Commit Summary

only forward touch events if node has user interaction enabled File Changes

M cocos2d/CCResponderManager.m (8) Patch Links:

https://github.com/cocos2d/cocos2d-iphone/pull/882.patch https://github.com/cocos2d/cocos2d-iphone/pull/882.diff — Reply to this email directly or view it on GitHub.

Birkemose avatar Jul 11 '14 10:07 Birkemose

Yes I was thinking about cancelling the touch as well. I would be fine with solution 2). Any other opinions on option 1) vs option 2)?

Ben-G avatar Jul 11 '14 20:07 Ben-G