Hello,
I want to add swipe functionality to one of my screens.
Screens are organized in storyboard like way - so to simplify it - let’s just talk about displayGroups.
I have displayGroup which has some interaction objects, mostly buttons. Common for interaction objects is having listener for touch event (in most cases they are listeners of they own touch event).
I want to add swipe functionality to be very simple to apply anywhere - so I use transparent rectangle covering all objects.
Issue comes when dealing touch event passing through - when I use return false in touch handler, event passes through and for example button is receiving it. This is good, but button is “hijaking” event, beacuse they way I want buttons work is that they have focus after receiving touch event and I don’t wanna change it.
Is there way of telling that event passed through overlaying object?
The other approach I’ve tried is dispatching touch event - this is the one that works the best, beacuse if finger is moved more than threshold I just dispatchEvent with “ended” phase with coordinates out of button bounds and this acts as button cancel - but is there any way to list all objects that have touch event listeners? Last resort here is iterating through all objects and checking if they have .touch method. But I don’t wanna do that, beacuse I have nested groups and it becomes even more complicated.
Another option is to add “swipe” listener to all touch listening objects - but again it requires obtaining list of these objects and would require adding object to that list everytime object with touch listener is created.
