Button press every 3 seconds without freezing?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 1
- Joined: Mon Feb 12, 2024 8:06 pm
Button press every 3 seconds without freezing?
Im trying to make it so a button can only be pressed every 3 seconds, how would i do this without using the wait command (it freezes the whole stack), thanks in advance
-
- VIP Livecode Opensource Backer
- Posts: 4013
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Button press every 3 seconds without freezing?
Hi DorianReedBased,
welcome to the forum.
I made a stack that shows one way of preventing a button to fire in less than 3 seconds from the last click.
It uses a 'script local variable' to store the time of the last click.
Such a variable must be declared outside and above of a handler hat uses it. Usually you declare them at the top of the script.
That variable is instantiated with 0. When the button is clicked the milliseconds are stored in the script local variable 'sLastClickTime'
The mouseUp handler checks the interval (3000 milliseconds) and if the time is passed that value then it fires.
Have a look at the script of the button.
Kind regards
Bernd
welcome to the forum.
I made a stack that shows one way of preventing a button to fire in less than 3 seconds from the last click.
It uses a 'script local variable' to store the time of the last click.
Such a variable must be declared outside and above of a handler hat uses it. Usually you declare them at the top of the script.
That variable is instantiated with 0. When the button is clicked the milliseconds are stored in the script local variable 'sLastClickTime'
The mouseUp handler checks the interval (3000 milliseconds) and if the time is passed that value then it fires.
Have a look at the script of the button.
Kind regards
Bernd
- Attachments
-
- button that fires only after 3 secs after last click.livecode.zip
- (1.02 KiB) Downloaded 26 times
-
- VIP Livecode Opensource Backer
- Posts: 9726
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Button press every 3 seconds without freezing?
Bernd.
Sure the name of your demo stack is long enough?
Craig
Sure the name of your demo stack is long enough?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9726
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Button press every 3 seconds without freezing?
I understand.
But couldn't you at least have made it more descriptive?
Craig
But couldn't you at least have made it more descriptive?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 4013
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: Button press every 3 seconds without freezing?
Ok, I am always aiming for baroque titles about half a page long.
How about
Kind regardsThis is the story of a press-down device that executes your wishes that you have put into the device in a language they call 'LiveCode' and that will not work unless you waited for at least 3 grains of sand down the hour glass. But then by mysterious magic it will execute the exact same orders it did before.
Bernd
-
- VIP Livecode Opensource Backer
- Posts: 9726
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Button press every 3 seconds without freezing?
Bernd.
Too long.
Craig
Too long.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Button press every 3 seconds without freezing?
What would I do without you guys. The seriousness and depth of your contributions is uplifting.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com