I think the calling order when a menu item is selected is not aligned between documentation and actual behaviour.
The documentation states:
Source: Inside Playdate
However the actual implementation appears to be (i.e. steps 2 and 3 are swapped):
- Hide the System Menu
- Unpause and call playdate.gameWillResume
- Invoke callback of menu item
Here is a minimal LUA project to show this:
playdate-test.zip (4.3 KB)
It will add a menu item "test", which when selected will print two lines into the developer console:
I think the behaviour described in the documentation is preferable. Having the menu item callback be called first, allows the developer to react to it and change the behaviour of the gameWillResume callback before it is called (which might do something differently compared to when the menu is just closed without a menu item being selected). Otherwise this would be harder to reproduce (i.e. the gameWillResume callback would have to just set a flag, which then is checked next update call alongside a flag set by the menu item callback to invoke the correct behavior...)
So I would love to see the implementation changed to match the documentation.
I have reproduced this with Firmware 2.1.1 in the emulator and on actual hardware.