Hi everyone,
Is there a way to have livecode ignore key presses during a certain period of time? I need the program to continue to execute other commands but also disregard any key presses during this phase. The keyDown code is set up similar to what is below:
on keyDown theKey
if theKey is K
then doSomething //this is a function in the code that tells what to do if the key is pressed
else if theKey is d
then doSomething
end if
end keyDown
I only need it to accept the d and k keys and ignore everything else, which it does from what I have tested. Now I need to limit when it accepts the d and k keys - after it's finished running some other code used to set up the screen.
Right now it runs the keyDown code whenever d or k is pressed. I need it to only register the key pressed given during the accepted time and ignore everything else.
Thanks for the help
Jeff
"Ignoring" messages
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: "Ignoring" messages
Hi Jeff,
quick idea: Use a global variable that holds "the seconds" and fill it when needed (opencard or whenever)!
Then you can do something like this:
Hint: ALWAYS use QUOTES around strings, like the values of theKey in this case!
Best
Klaus
quick idea: Use a global variable that holds "the seconds" and fill it when needed (opencard or whenever)!
Code: Select all
on opencard
global gStartSeconds
put the seconds into gStartSeconds
## More opencard stuff here...
end opencard
Code: Select all
on keyDown theKey
global gStartSeconds
## Say you want to STOP entering data after 60 secs after you started the app:
if the seconds - gStartSeconds >= 60 then
beep
exit keydown
end if
switch theKey
case "K"
doSomething //this is a function in the code that tells what to do if the key is pressed
break
case "d"
doSomething
break
end switch
end keyDown
Best
Klaus
Re: "Ignoring" messages
Thank you Klaus! This will work nicely with me current code.
And thanks for the hint, but what might happen without the quotations? I've run it several time through using the code without quotations and haven't noticed anything unusual.
Thanks!
Jeff
And thanks for the hint, but what might happen without the quotations? I've run it several time through using the code without quotations and haven't noticed anything unusual.
Thanks!
Jeff
Re: "Ignoring" messages
Hi Jeff,
the engine is less and less "forgiving" worth every new version, as I had experienced in the past,
so sticking to the correct syntax will not hurt now but save some headache in the future
Best
Klaus
the engine is less and less "forgiving" worth every new version, as I had experienced in the past,
so sticking to the correct syntax will not hurt now but save some headache in the future

Best
Klaus