Touch event on overlapping bittons

I have a button that after being touch, brings up a tableView. As the first button position on top of the tableView after being touched, triggers event of the tableView as well. I tried to put “ended” phase so only brings up the tableView after disappearing the button but no luck. Is a work around it (preferably not a timer delay) or I have to use different positions for these two?

local function ProjectList( event ) print(event.phase) if ( "ended" == event.phase ) then print(event.phase)     recordGroup:removeSelf() tableView.isVisible=true end end

Hi @af6,

This is expected behavior unless you “return true” from the button listener, to prevent the touch from propagating through to object(s) behind. Please see this guide for details:

https://docs.coronalabs.com/guide/events/touchMultitouch/index.html

Take care,

Brent

I added that but still both are triggered.

local function ProjectList( event ) print(event.phase) if ( "ended" == event.phase ) then print(event.phase)     recordGroup:removeSelf() tableView.isVisible=true end return true end

Hi @af6,

When you say it “triggers the tableView”, what exactly does it do? Does it send an event to a particular tableView row? Or does it make the tableView scroll?

Brent

Yes Brent. As you see the function makes the tableview visible. But also triggers the event as you have touched the rows. Return true doesn’t make any difference.

Hi @amirfarazmand,

I know you want to avoid the timer method, but how about a compromise? Show the tableView immediately (no timer delay), but set it as “locked” for a short timer delay (say 50-100 milliseconds). Then after that timer triggers, unlock it… this should prevent you getting a touch response that you don’t want/need.

https://docs.coronalabs.com/api/type/TableViewWidget/setIsLocked.html

Best regards,

Brent

Hi @af6,

This is expected behavior unless you “return true” from the button listener, to prevent the touch from propagating through to object(s) behind. Please see this guide for details:

https://docs.coronalabs.com/guide/events/touchMultitouch/index.html

Take care,

Brent

I added that but still both are triggered.

local function ProjectList( event ) print(event.phase) if ( "ended" == event.phase ) then print(event.phase)     recordGroup:removeSelf() tableView.isVisible=true end return true end

Hi @af6,

When you say it “triggers the tableView”, what exactly does it do? Does it send an event to a particular tableView row? Or does it make the tableView scroll?

Brent

Yes Brent. As you see the function makes the tableview visible. But also triggers the event as you have touched the rows. Return true doesn’t make any difference.

Hi @amirfarazmand,

I know you want to avoid the timer method, but how about a compromise? Show the tableView immediately (no timer delay), but set it as “locked” for a short timer delay (say 50-100 milliseconds). Then after that timer triggers, unlock it… this should prevent you getting a touch response that you don’t want/need.

https://docs.coronalabs.com/api/type/TableViewWidget/setIsLocked.html

Best regards,

Brent