menu:on_mouse_released() gets called twice
If in the menu:on_mouse_released()
event a new menu is started, then the original menu:on_mouse_released()
event gets called a second time.
Steps to Reproduce
- Create a new quest
- Replace the contents of solarus_logo.lua with the following:
local menu = {}
function menu:on_mouse_released(button, x, y)
print("clicked!", self, button, x, y)
sol.menu.start(sol.main, {on_started = function(self) print"started another menu" end})
end
return menu
- Run the quest and click anywhere in the black screen
Console Output:
clicked! table: 0x0c394418 left 164 162
started another menu
clicked! table: 0x0c394418 left 164 162
started another menu
Workaround
Adding a 10ms delay before starting the second menu resolves the issue:
local menu = {}
function menu:on_mouse_released(button, x, y)
print("clicked!", self, button, x, y)
sol.timer.start(sol.main, 10, function()
sol.menu.start(sol.main, {on_started = function(self) print"started another menu" end})
end)
end
return menu
returning true in the menu:on_mouse_released()
event also fixes the issue, but in my case I want the event to propagate to multiple menus so that isn't a viable solution for my use case.