Can't really do closures for EventListeners, can you?

I mean, you can do something like:

WholeScreen:addEventListener(“touch”, function(e) return true; end)

but then later you cannot do a removeEventListener for it. At least I don’t see any way to do that. Is there some trick that allows using closures for EventListeners? Would be very handy. [import]uid: 160496 topic_id: 29856 reply_id: 329856[/import]

yes, you can do WholeScreen:addEventListener(“touch”, function(e) return true; end)

but you cannot do WholeScreen:removeEventListener(“touch”, function(e) return true; end)

because you dont have any reference for closure function, but you can still remove whole listeners functions by doing so:

WholeScreen._functionListeners = nil --this will remove all functions listeners
WholeScreen._tableListeners = nil --this will remove all table listeners [import]uid: 147582 topic_id: 29856 reply_id: 119776[/import]

Thanks. Didn’t know that was possible. Should be added to docs :slight_smile: [import]uid: 160496 topic_id: 29856 reply_id: 119800[/import]

yes, you can do WholeScreen:addEventListener(“touch”, function(e) return true; end)

but you cannot do WholeScreen:removeEventListener(“touch”, function(e) return true; end)

because you dont have any reference for closure function, but you can still remove whole listeners functions by doing so:

WholeScreen._functionListeners = nil --this will remove all functions listeners
WholeScreen._tableListeners = nil --this will remove all table listeners [import]uid: 147582 topic_id: 29856 reply_id: 119776[/import]

Thanks. Didn’t know that was possible. Should be added to docs :slight_smile: [import]uid: 160496 topic_id: 29856 reply_id: 119800[/import]