Swipe class

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.

Or add big invisible rect at the top of the screen and make it detect touch events (isHitTestable)

piotrz55

This is what I have.

And what you wrote is not even close to solution. I need that rectangle to pass events deeper… but in very specific manner, returning false on touch handler is not a way to go.

Just do not return anything. Layer will still detect touch but will pass event further. When touch reaches button then you can set focus on it and return true.

Sorry dude, but did you even read my post? :slight_smile:

Or add big invisible rect at the top of the screen and make it detect touch events (isHitTestable)

piotrz55

This is what I have.

And what you wrote is not even close to solution. I need that rectangle to pass events deeper… but in very specific manner, returning false on touch handler is not a way to go.

Just do not return anything. Layer will still detect touch but will pass event further. When touch reaches button then you can set focus on it and return true.

Sorry dude, but did you even read my post? :slight_smile: