Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on March 04, 2016, 09:11:53 PM

Title: Lua Key Press question
Post by: garry23 on March 04, 2016, 09:11:53 PM
David  :)

I have this simple test script: but it doesn't respond as I would expect:

event.keypress = function(key)
if key == KEY.PLAY then
display.notify_box (key,3000)
return false
else
return true
end
end


I would expect the notify to display only if PLAY is pressed, ie value 24; and play is not enacted by Canon, ie return false.

What seems to happen is notify is called every time a key is pressed.

Any hints what I'm missing?
Title: Re: Lua Key Press question
Post by: garry23 on March 04, 2016, 10:49:26 PM
David

Sorry, still getting confused.

Why does this create errors?

event.keypress = function(key)
if key == KEY.PLAY then
key.press(KEY.PLAY)
return false
else
return true
end
end
Title: Re: Lua Key Press question
Post by: dmilligan on March 05, 2016, 01:49:07 AM
I'm surprised it doesn't lock up the camera. Theoretically you've set up an infinite loop.
Title: Re: Lua Key Press question
Post by: garry23 on March 05, 2016, 08:11:33 AM
Of course: how stupid of me.

The Lua key.press will call the event handler, that's running!!!

I was trying to see if I could use Lua to reprogram functionality to the PLAY key.

My thought was to reprogam PLAY to operate like the ETTR SET, which, unfortunately is not in the ML EOS-M version.

Once again, thanks for the (obvious  :-[) pointer.