Oops, looks like I completely misunderstood the problem, sorry...dunbarx wrote: ↑Wed Jun 19, 2024 5:19 pmKlaus.
The OP wrote:Didn't the OP want to be able to stop (or divert?) execution of a running handler by hitting the enter key?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?
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
How to detect user holding enter key down
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: How to detect user holding enter key down
-
- Livecode Opensource Backer
- Posts: 10078
- Joined: Fri Feb 19, 2010 10:17 am
Re: How to detect user holding enter key down
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
- Attachments
-
- Fibonacci.livecode.zip
- Stack.
- (21.85 KiB) Downloaded 109 times
Re: How to detect user holding enter key down
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:
Craig
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
Re: How to detect user holding enter key down
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
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
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to detect user holding enter key down
Quite possibly. I've requested clarification on the use case, and look forward to the OP's return so we're no longer guessing.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to detect user holding enter key down
Me too.CAsba, please be precise. What do you want to do?
Craig
Re: How to detect user holding enter key down
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).
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
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: How to detect user holding enter key down
No worries, I'm just glad you have a good solution. Bother us anytime.CAsba wrote: ↑Fri Jun 21, 2024 10:23 amHi 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).
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: How to detect user holding enter key down
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
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