Author Topic: Lua Key Press question  (Read 4708 times)

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1957
Lua Key Press question
« on: March 04, 2016, 09:11:53 PM »
David  :)

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

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

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1957
Re: Lua Key Press question
« Reply #1 on: March 04, 2016, 10:49:26 PM »
David

Sorry, still getting confused.

Why does this create errors?

Code: [Select]
event.keypress = function(key)
if key == KEY.PLAY then
key.press(KEY.PLAY)
return false
else
return true
end
end

dmilligan

  • Developer
  • Hero Member
  • *****
  • Posts: 3218
  • 60Da / 1100D / EOSM
Re: Lua Key Press question
« Reply #2 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.

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1957
Re: Lua Key Press question
« Reply #3 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.