I now open the menu with task.create().
task.create(function()
menu.open()
end)
This way at least my script will open the menu reliably.
I tried to experiment a bit with the priority of the task.create() function.
But I don't understand how to specify the priority.
The docs say I should specify with an integer, but this doesn't work:
task.create(function()
menu.open()
end, 31)
Also this doesn't work:
task.create(function()
menu.open()
end, 0x1F)
My current problem is that the menu opens fine, but seems to capture keypresses in a strange way when it's opening.
See the minimal example below. When you run the script and press the PLAY button in Live View, it will open the ML menu.
If you wait for it to open and press PLAY again, it will close the menu.
But when you start in Live View and quickly tap PLAY twice, it will open ML menu en the submenu if the selected item in ML menu.
Seems like the key event doesn't even make it to my script in this scenario...
-- aa PLAY key test
-- Test
menu_opening = false
event.keypress = function(k)
-- Check if PLAY key is pressed
if k ~= KEY.PLAY then
-- Pressed other key
return true
end
-- Get out of ML menu
if(menu_opening == true) then
menu_opening = false
task.create(function()
menu.close()
end)
return false
end
-- Open the presets menu
-- Camera glitches if not calling with task.create...
menu_opening = true
task.create(function()
menu.open()
end)
return false
end