mirror of
https://github.com/love2d/love.git
synced 2026-08-12 16:40:57 +02:00
Added love.event.addListener and removeListener.
addListener takes a function, and names of events that will trigger the function when they're processed inside love.event.poll or love.event.wait. When the given listener function is called, the name of the event as well as all of the event's arguments are passed to the function. If addListener is called multiple times with the same function and events, it will not add the function more than once. removeListener takes a function and removes it from all events it was previously added to.
This commit is contained in:
+11
-1
@@ -243,7 +243,17 @@ int luax_register_module(lua_State *L, const WrappedModule &m)
|
||||
|
||||
// Register all the functions.
|
||||
if (m.functions != nullptr)
|
||||
luax_setfuncs(L, m.functions);
|
||||
{
|
||||
const luaL_Reg *l = m.functions;
|
||||
|
||||
for (; l->name != nullptr; l++)
|
||||
{
|
||||
// Set the module's table as an upvalue for the module's functions.
|
||||
lua_pushvalue(L, -1);
|
||||
lua_pushcclosure(L, l->func, 1);
|
||||
lua_setfield(L, -2, l->name);
|
||||
}
|
||||
}
|
||||
|
||||
// Register types.
|
||||
if (m.types != nullptr)
|
||||
|
||||
Reference in New Issue
Block a user