Touch event propagating through multiple buttons

It used to be that we could “return true” in a function and that would stop a touch from propagating to other buttons/tableviews/etc that were positioned behind/underneath that button which was pressed.

This no longer works to prevent a touch from propagating to other touchable objects below it.

Any help would be greatly appreciated!  Thanks!

Hi @ranflas,

This still works, so we’d have to see some code to determine why things are “passing through”.

Brent

Hi @ranflas,

This still works, so we’d have to see some code to determine why things are “passing through”.

Brent

I’m also having a similar issue. My touch event is propagating through my buttons even though i wrote return true in the button’s event handler.

Image: http://imgur.com/5b0DOpO

Code(zip): https://www.mediafire.com/?y8vih1ldq0uolon (Sorry, I can’t seem to be able to attach files to my post)

Could it be that you have one object which uses “touch” and another which uses “tap”?

Afaik using “return true” will only stop events propagating through to objects which use the same event type.  

That solved it! :slight_smile:

Thanks, this solved my issue over my Tableview  touch events. :slight_smile:

I’m also having a similar issue. My touch event is propagating through my buttons even though i wrote return true in the button’s event handler.

Image: http://imgur.com/5b0DOpO

Code(zip): https://www.mediafire.com/?y8vih1ldq0uolon (Sorry, I can’t seem to be able to attach files to my post)

Could it be that you have one object which uses “touch” and another which uses “tap”?

Afaik using “return true” will only stop events propagating through to objects which use the same event type.  

That solved it! :slight_smile:

Thanks, this solved my issue over my Tableview  touch events. :slight_smile:

Hi,

I’ve tried adding “return true” to my touch listeners but find it is still firing multiple times. Any ideas on what I’m missing?

local function goToMyPostsPage ( event ) if ( event.phase == "ended" ) then composer.gotoScene( "myPostsPage", "slideLeft", 100 ) end return true end local function goToMoreOptions ( event ) if ( event.phase == "ended" ) then composer.gotoScene( "options", "slideLeft", 100 ) end return true end local postPage = display.newImage( "images/postPageBtn.png", ..., ... ) postPage:addEventListener( "touch", goToMyPostsPage ) local optionsPage = display.newImage( "images/optionsBtn.png", ..., ... ) optionsPage:addEventListener( "touch", goToMoreOptions )

Is this all there is to the code for those objects? If you are seeing the function being fired multiple times, I would assume you are adding the event listener more than once.

Ah, that was it. I had added another event listener to the object in a different scene.

Thank you!

Hi,

I’ve tried adding “return true” to my touch listeners but find it is still firing multiple times. Any ideas on what I’m missing?

local function goToMyPostsPage ( event ) if ( event.phase == "ended" ) then composer.gotoScene( "myPostsPage", "slideLeft", 100 ) end return true end local function goToMoreOptions ( event ) if ( event.phase == "ended" ) then composer.gotoScene( "options", "slideLeft", 100 ) end return true end local postPage = display.newImage( "images/postPageBtn.png", ..., ... ) postPage:addEventListener( "touch", goToMyPostsPage ) local optionsPage = display.newImage( "images/optionsBtn.png", ..., ... ) optionsPage:addEventListener( "touch", goToMoreOptions )

Is this all there is to the code for those objects? If you are seeing the function being fired multiple times, I would assume you are adding the event listener more than once.

Ah, that was it. I had added another event listener to the object in a different scene.

Thank you!