No way to pass arguments through event listener?

Is there really no way to pass arguments through :addEventListener() to the function you call?

I know I can add a custom property but I am just curious.

What are you specifically trying to accomplish?

You could always dispatch an event, but I don’t think you can pass arguments to the function at the time you add the listener.

This is the way: https://docs.coronalabs.com/tutorial/basics/anonymousFunctions/index.html

1 Like

I mean my examples are too complex so i’ll just create a simple one.

button:addEventListener("tap", myFunc(5))

local function myFunc(num)
num = num/2
end
1 Like

oh thanks. Solved.

1 Like