Closed superquadratic closed 11 years ago
Implementation initially, I was thinking how to use the following.
local function onTest(e)
print("hello!")
e.target:removeEventListener(e.type, e.callback)
end
local obj = EventDispatcher()
obj:addEventListener("test", onTest)
obj:dispatchEvent("test")
If you want to remove an event listener, you can retrieve the information from the Event object. However, I do not know there are people who have this help.
This process is still necessary. That compatibility is lost is also a worry.
local button = widget.Button {
size = {200, 50},
text = "Hello",
onClick = function(e)
print("Hello")
e.target:removeEventListener(e.type, e.callback)
end,
}
That makes perfect sense, let's leave it as it is then!
Maybe I overlooked something, but to me it seems like
Event:setListener()
is not really needed anymore. Would it be OK to remove it or does anyone use thecallback
andsource
properties of theEvent
object?