Lua key press redirect

Started by garry23, March 18, 2016, 10:44:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

David (if your watching :) )

I'm trying to be clever and redirect a key press. The following script is meant to intercept the press of the play button and turn this into a half shutter press. But it doesn't seem to work. The play button responds as if play was pressed. Any ideas where I'm going wrong in this test script?

test_menu = menu.new
{
    name = "Show keypress",
    choices = { "Off", "On" },
    value = "On",
}

function event.keypress(key)
    if key == KEY.PLAY and test_menu.value == "On" then
key = UNPRESS_HALFSHUTTER
return true
end
end

dmilligan

Function parameters are "pass by value". Setting them will have no effect on the caller.

garry23

David

Thanks. BTW is the custom_picture_taking (arg) functionality working in the Lua event module?

If so how do I use this within a Lua script?

Finally, I assume this is the correct use of the press function in the Lua key module?

key.press(HALFSUTTER)

Cheers

Garry