Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on January 11, 2017, 06:16:42 PM

Title: ML Menu interactions
Post by: garry23 on January 11, 2017, 06:16:42 PM
Just some feedback on ML use.

I have a script running that detects I'm in the ML menu and (on the EOSM) converts the [INFO] button into a dedicated [Q] button, so I can go in and out of the ML menus with ease, ie without touching the screen, eg if I have gloves on.

Here is the relevant redacted part of the script:

if menu.visible then
if key == KEY.INFO then -- sim [Q] test
q_pressed = true
return false
else
return true
end
end


All is OK, until you switch on the intervalometer, whilst staying in the ML menu: then the above code doesn't work.

Strange  ???
Title: Re: ML Menu interactions
Post by: garry23 on January 11, 2017, 06:29:34 PM
Should have said that the other part of my script looks like this:

function simq(arg)
if q_pressed and menu.visible then
key.press(KEY.Q)
q_pressed = false -- reset
return false
else
return true
end
end

event.shoot_task = simq
Title: Re: ML Menu interactions
Post by: a1ex on January 11, 2017, 07:21:23 PM
You should be able to send the Q event directly from the GUI task (no need for a shoot_task hook).
Title: Re: ML Menu interactions
Post by: garry23 on January 11, 2017, 07:34:20 PM
@A1ex

The strangeness is that the script works fine for every other ML menu, i.e. My keypress using [INFO] button to simulate Q works perefectly. As soon as you switch on the intervalometer in the ML menu, it stops working. Only in that case.

Not sure what you mean by from the GUI task, unless you mean the screen touch and don't wish to use that.

On the EOSM because Q and SET are the same button, you don't have a dedicated Q. Which ISO why I wrote the script.

Bottom line: I'm not 'worried' about the behavior, as I know it exists and can work round it.
Title: Re: ML Menu interactions
Post by: a1ex on January 11, 2017, 07:38:00 PM
I mean something like this:


if menu.visible then
if key == KEY.INFO then -- sim [Q] test
key.press(KEY.Q)
return false
else
return true
end
end


The issue is that shoot_task hook doesn't run while the intervalometer is active. Can be changed if it makes sense.
Title: Re: ML Menu interactions
Post by: garry23 on January 11, 2017, 07:48:48 PM
Makes sense: thanks  :)
Title: Re: ML Menu interactions
Post by: garry23 on January 11, 2017, 09:18:32 PM
@A1ex

Justed tested out your suggestion and it doesn't work. In fact I remembered why I had to go the event.shoot_task route.

The reason, I think, is that I am already 'inside' event.keypress, thus calling key.press(x) wont work.

Or at least it doesn't seem to work, ie cbr error.

Unless you think I'm wrong, I'll go back to just setting the flag inside event.keypress and using that flag in event.shoot_task, and live with the minor intervalometer 'feature' when the ML menu is showing.

Cheers

Garry
Title: Re: ML Menu interactions
Post by: a1ex on January 11, 2017, 09:51:11 PM
Minimal example:


-- Open ML submenus with INFO

function test4Q(k)
if k == KEY.INFO and menu.visible then
key.press(KEY.Q)
return false
else
return true
end
end

event.keypress = test4Q


BTW, please don't forget Audionut's advice (http://www.magiclantern.fm/forum/index.php?topic=18555.msg177814#msg177814).
Title: Re: ML Menu interactions
Post by: garry23 on January 11, 2017, 10:18:47 PM
@A1ex/@Audionut

Forgot the 'Lua guidance' : Sorry.

Also worked out what was going wrong, I had tried what you did but it didn't work: why?

Because, stupidly I was doing this:

function test4Q(key)
if key == KEY.INFO and menu.visible then
key.press(KEY.Q)
return false
else
return true
end
end

event.keypress = test4Q


That is using "key", ie you used "k". I changed it to something else and all is OK.

Many thanks for the help/education.

Cheers

Garry