Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Touch event propagating through multiple buttons
Started by ranflas Jan 24 2014 10:02 AM

- - - - -
8 replies to this topic
button corona android ios
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ranflas

[GLOBAL: userInfoPane.html]
ranflas
  • Enthusiast

  • 74 posts
  • Corona SDK

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!

 



[TOPIC: post.html]
#2

bjsorrentino

[GLOBAL: userInfoPane.html]
bjsorrentino
  • Veteran

  • 8,506 posts
  • Corona SDK

Hi @ranflas,

This still works, so we'd have to see some code to determine why things are "passing through".

 

Brent



[TOPIC: post.html]
#3

atrizhong

[GLOBAL: userInfoPane.html]
atrizhong
  • Enthusiast

  • 95 posts
  • Corona SDK

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)



[TOPIC: post.html]
#4

AlanPlantPot

[GLOBAL: userInfoPane.html]
AlanPlantPot
  • Contributor

  • 733 posts
  • Corona SDK

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.  



[TOPIC: post.html]
#5

atrizhong

[GLOBAL: userInfoPane.html]
atrizhong
  • Enthusiast

  • 95 posts
  • Corona SDK

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! :)



[TOPIC: post.html]
#6

alzaabi98

[GLOBAL: userInfoPane.html]
alzaabi98
  • Contributor

  • 354 posts
  • Corona SDK

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.  

 

 

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



[TOPIC: post.html]
#7

jeremiahflickinger

[GLOBAL: userInfoPane.html]
jeremiahflickinger
  • Observer

  • 14 posts
  • Corona SDK

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 )


[TOPIC: post.html]
#8

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 928 posts
  • Corona SDK

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.



[TOPIC: post.html]
#9

jeremiahflickinger

[GLOBAL: userInfoPane.html]
jeremiahflickinger
  • Observer

  • 14 posts
  • Corona SDK

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

 

Thank you!




[topic_controls]
[/topic_controls]