How does tap detection work?

Based on Solar2D Documentation β€” Developer Guides | Events/Listeners, tap is a single action but why does it output 2 values (see example below)?
Sample code:

local function listener(event)
 print("a")
end
text:addEventListener("tap", listener)

Output:

a
a

P.S. Both values are printed at the same time

Your sample code isn’t enough to reproduce the problem. Your problem may be caused by you having attached the same listener to multiple objects and not having a return true at the end to stop tap events from propagating. The tap event listener does only fire once, as the docs state.

local object = display.newRect( 100, 100, 100, 100 )

local function onObjectTap( event )
	print( "a" )
	return true
end

object:addEventListener( "tap", onObjectTap )
1 Like