button

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ferhan24badshah
Posts: 35
Joined: Sun Feb 02, 2014 12:20 am

button

Post by ferhan24badshah » Thu Feb 20, 2014 10:26 pm

How do I code a button so that after it is clicked once, it goes through the code embedded in that button...then it waits 5 seconds...then it goes through the code again without having to click the button again.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: button

Post by jmburnod » Thu Feb 20, 2014 10:58 pm

Salaam Ferhan,

I think you need use a send message in time to do it
Have a look to "send" command in dictionary

Best regards
Jean-Marc
https://alternatic.ch

ferhan24badshah
Posts: 35
Joined: Sun Feb 02, 2014 12:20 am

Re: button

Post by ferhan24badshah » Thu Feb 20, 2014 11:22 pm

jmburnod wrote:Salaam Ferhan,

I think you need use a send message in time to do it
Have a look to "send" command in dictionary

Best regards
Jean-Marc
Was salaam

I tried using the send but it didnt seem to work...my code looks like this

this is button "Button"

on mouseUp
answer "hii"
send "mouseDown" to button "Button" in 5 seconds
end mouseUP

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: button

Post by Simon » Fri Feb 21, 2014 12:11 am

Hi Ferhan,
on mouseUp
answer "hii"
send "mouseDown" to button "Button" in 5 seconds
end mouseUP
I'll quiz you on this one because finding things yourself is more fun.
What is the name of the command above?
What is the name of the command you wish to trigger after 5 seconds?

If you still need help just ask.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

ferhan24badshah
Posts: 35
Joined: Sun Feb 02, 2014 12:20 am

Re: button

Post by ferhan24badshah » Fri Feb 21, 2014 12:22 am

Simon wrote:Hi Ferhan,
on mouseUp
answer "hii"
send "mouseDown" to button "Button" in 5 seconds
end mouseUP
I'll quiz you on this one because finding things yourself is more fun.
What is the name of the command above?
What is the name of the command you wish to trigger after 5 seconds?

If you still need help just ask.

Simon
ohh i figured it out.....it should've been ....send "mouseUp" instead of send "mouseDown" =p , thanks.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: button

Post by Simon » Fri Feb 21, 2014 1:21 am

:D Glad you figured it out

To save your sanity you will want a way to break out of your loop so

Code: Select all

on mouseUp
   answer "hii"
   if the optionKey is up then --alt key on win 
      send "mouseUp" to me in 5 seconds --Note the "to me" as the command is in the button
   end if
end mouseUp
Then there is the "pendingMessages" which you should look up with it's pal "cancel".

Code: Select all

global gCancel
on mouseUp
   beep
   send "mouseUp" to me in 5 second
   put the result into gCancel
end mouseUp
and in the card script

Code: Select all

global gCancel
on optionKeyDown 
  cancel gCancel
end optionKeyDown
Note now you don't have to hold down the option key.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply