Page 2 of 2
Re: How to detect user holding enter key down
Posted: Wed Jun 19, 2024 5:57 pm
by Klaus
dunbarx wrote: Wed Jun 19, 2024 5:19 pm
Klaus.
The OP wrote:
Code: Select all
Is there a SIMPLE way that key holding could be detected in a way that a script could be activated to abandon the current task?
Didn't the OP want to be able to stop (or divert?) execution of a
running handler by hitting the enter key?
Your gadget initializes the local variable, but that only stops execution of the handler after the "clean-up" lines are processed, not the handler itself the moment the enter key is pressed.
CAsba, please be precise. What do you want to do?
Craig
Oops, looks like I completely misunderstood the problem, sorry...
Re: How to detect user holding enter key down
Posted: Wed Jun 19, 2024 7:30 pm
by richmond62
-
Script of button RUN:
Code: Select all
on mouseUp
put empty into fld "VALZ"
put 1 into KOUNT
put 0 into A
put 1 into B
repeat until KOUNT > 1000
put A + B into C
put B into A
put C into B
put KOUNT & " : " & A into line KOUNT of fld "VALZ"
wait for 25 ticks with messages
add 1 to KOUNT
end repeat
end mouseUp
on enterKey
exit to top
end enterKey
Re: How to detect user holding enter key down
Posted: Wed Jun 19, 2024 8:43 pm
by dunbarx
Richmond.
I thought this was really a good one. The key of course is the "with messages", allowing LC to peek at the world it lives in and see if any enter keys are down. The only drawback, and it is a tiny one, is that the enter key has to be pressed during the wait time. Hardly an issue.
But there is something I do not understand, assuming anything I said above is valid. This handler does not respond to an enter key at all:
Code: Select all
on mouseUp
repeat 1000
repeat with y = 1 to 10
put y into fld 1
wait 5 -- cycle quickly through some integers
end repeat
wait 60 with messages --wait for the "10", ostensibly plenty of time to hit the enter key
end repeat
end mouseUp
on enterKey
exit to top
end enterKey
Craig
Re: How to detect user holding enter key down
Posted: Thu Jun 20, 2024 12:06 pm
by Cairoo
Guys.
I think we've misunderstood what the OP wants. He seems to want to know how to handle the enter key only once while the enter key is down, i.e. do something when the enter key is pressed, but only once, until the enter key is released.
Gerrie
Re: How to detect user holding enter key down
Posted: Thu Jun 20, 2024 5:24 pm
by FourthWorld
Cairoo wrote: Thu Jun 20, 2024 12:06 pm
I think we've misunderstood what the OP wants.
Quite possibly.
I've requested clarification on the use case, and look forward to the OP's return so we're no longer guessing.
Re: How to detect user holding enter key down
Posted: Thu Jun 20, 2024 6:53 pm
by dunbarx
CAsba, please be precise. What do you want to do?
Me too.
Craig
Re: How to detect user holding enter key down
Posted: Fri Jun 21, 2024 10:23 am
by CAsba
Hi guys,
Yes, I should have been more precise. I was concerned that user may hold enter key down, in reply to an ask dialog without entering a reply. I found that the following code ensures that it won'tb happen. Sorry to have used up your valuable time (I know - AGAIN).
Code: Select all
put empty into cost
repeat until cost is a number
ask "Enter the minimum purchaseable quantity of packs (numerals only)" titled field "fieldboxtitle" of cd "template1"
put it into cost
put cost into fld "fmin.purchqty"
if cost is not a number or cost <0 or cost is empty then
put empty into cost
answer "Try again. You must enter a numeral above zero."titled field "fieldboxtitle" of cd "template1"
end if
end repeat
Re: How to detect user holding enter key down
Posted: Sat Jun 22, 2024 5:00 am
by FourthWorld
CAsba wrote: Fri Jun 21, 2024 10:23 am
Hi guys,
Yes, I should have been more precise. I was concerned that user may hold enter key down, in reply to an ask dialog without entering a reply. I found that the following code ensures that it won'tb happen. Sorry to have used up your valuable time (I know - AGAIN).
No worries, I'm just glad you have a good solution. Bother us anytime.
Re: How to detect user holding enter key down
Posted: Sat Jun 22, 2024 2:43 pm
by dunbarx
Casba
So the whole thing was about data entry and validation, and nothing to do with holding down the enter key.
OK. Hard to communicate clearly.
At least we had a lively discussion about pressing control-type keys.
Craig