How to avoid overlapping touch listeners

In my app two touch listeners are getting overlapped and I want that the object in foreground should receive the listener but exactly opposite is happening, i.e the listener of the below object is executing.

Can I set the preferences of these overlapping touch listeners.

Thanks

In your touch listener, if you don’t want the touch event to propagate down to other touch listeners, you need to return true:

function touch(e)     print(e.name)     return true -- this stops the event from dropping to the display object below end local a = display.newCircle(100,100,100) a:addEventListener("touch",touch)a:setFillColor(255,0,0) a.name = "A" local b = display.newCircle(200,100,100) b:addEventListener("touch",touch)b:setFillColor(255,0,0) b.name = "B"

In your touch listener, if you don’t want the touch event to propagate down to other touch listeners, you need to return true:

function touch(e)     print(e.name)     return true -- this stops the event from dropping to the display object below end local a = display.newCircle(100,100,100) a:addEventListener("touch",touch)a:setFillColor(255,0,0) a.name = "A" local b = display.newCircle(200,100,100) b:addEventListener("touch",touch)b:setFillColor(255,0,0) b.name = "B"