Author Topic: Slow to close ML menu  (Read 271 times)

Jip-Hop

  • Freshman
  • **
  • Posts: 87
Slow to close ML menu
« on: July 09, 2019, 01:31:12 PM »
When I close the ML menu from a script, it flashes first, then closes but briefly shows a slider with "Darker" and "Brighter" on each end (I guess it's the exposure compensation slider) and then goes to Live View. It's quite slow, almost 2 seconds on my EOS M with Danne's crop_rec_4k_mlv_snd_isogain_1x3_presets_2019Jul01.EOSM202.

But when I'm in the ML menu, pressing the canon MENU button goes back to Live View instantly! How can I instantly quit the ML menu and go to Live View from a LUA script?

Code: [Select]
-- INFO key menu

event.keypress = function(k)
    -- Check if INFO key is pressed
    if k == KEY.INFO then
        menu.close();
        return false;
    end
end

Jip-Hop

  • Freshman
  • **
  • Posts: 87
Re: Slow to close ML menu
« Reply #1 on: July 09, 2019, 06:46:23 PM »
Actually it seems I'm unable to open the menu reliably from this simple snippet as well:

Code: [Select]
-- INFO key menu

event.keypress = function(k)
    -- Check if INFO key is pressed
    if k == KEY.INFO then
        menu.open();
        return false;
    end
end

It will often end up in this slider menu with Darker and Brighter on both ends. Tried with the PLAY and SET keys too but with same results.

What am I missing?

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12282
  • Emergencies only
Re: Slow to close ML menu
« Reply #2 on: July 09, 2019, 07:05:29 PM »
Didn't try, but Lua wrappers for menu.open/close (lua_menu.c) have a delay of one second, i.e. they are meant to be called from a regular script body and wait for the menu (which operates in its own task) to finish opening or closing.

Otherwise, I'd expect it to work. Maybe that delay isn't needed in the first place?

Jip-Hop

  • Freshman
  • **
  • Posts: 87
Re: Slow to close ML menu
« Reply #3 on: July 11, 2019, 04:40:06 PM »
I now open the menu with task.create().

Code: [Select]
    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:

Code: [Select]
    task.create(function()
        menu.open()
    end, 31)

Also this doesn't work:
Code: [Select]
    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...

Code: [Select]
-- 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