Handle touch events in a hierarchical manner

Handle touch events in a hierarchical manner
0.0 0


I’m curious if it’s possible to handle touch events in a hierarchical manner. Right now if I register the root layer touch handlers as targeted, it blocks all its children except menu and menu items. If there a way to get around this?


It does that by default. Layers “swallow” touches.

At the end of your ccTouchBegan, you should returnfalse if you want your touches to propagate into child objects. If you always set to true, touch will not propagate to child objects.


touch events are simply not handled in a hierarchical manner. You could make layers swallow touches but it’s not done hierarchically, especially not for its children “menu”s. As I later figured out, I could give the swallowing layer’s targeted touch delegate a really high priority to have it run before all other touch delegates. That would get me close to what I want but it feels kinda hacky.