love.event.poll() and quit event
Posted: Fri Aug 21, 2020 1:06 am
Hi there o/
I'm currently working on a new UI library for love2d. I'm implementing a custom event dispatcher for my new library and notice something in the love.run default implementation. I'm using the version 11.3
The thing that bothers me is the following code line:
It's the part with the "return a or 0". I don't get why "a" is here in the first place. The love.quit function doesn't take any inputs and I thought the parameter a-f in the love.event.poll function fetches these values for using them as parameter for the event handler. So, why is there "a" in the return value in the first place? What is the meaning for it?
I'm thinking of adding another parameter for all love event callbacks in order to indicate if my library already used this event for one of the UI elements. I just add a system to add event dispatcher for UI elements and give them own callback functions. This will prevent accidentally breaking the library apart while still using the love event callbacks for normal stuff. I already have a workaround specifically for the love.quit callback. But I'm still wondering why this "a" is here and what purpose it have in combination with the quit event.
I'm currently working on a new UI library for love2d. I'm implementing a custom event dispatcher for my new library and notice something in the love.run default implementation. I'm using the version 11.3
The thing that bothers me is the following code line:
Code: Select all
if name == "quit" then
if not love.quit or not love.quit() then
return a or 0
end
end
I'm thinking of adding another parameter for all love event callbacks in order to indicate if my library already used this event for one of the UI elements. I just add a system to add event dispatcher for UI elements and give them own callback functions. This will prevent accidentally breaking the library apart while still using the love event callbacks for normal stuff. I already have a workaround specifically for the love.quit callback. But I'm still wondering why this "a" is here and what purpose it have in combination with the quit event.
Code: Select all
if love.event then
love.event.pump()
for n, a, b, c, d, e, f in love.event.poll() do
local g = yui.event.dispatcher(n, a, b, c, d, e, f)
if n == "quit" then
if not love.quit or not love.quit(g) then
return a or 0
end
end
a = a or g
b = b or g
c = c or g
d = d or g
e = e or g
f = f or g
love.handlers[n](a, b, c, d, e, f, g)
end
end