monitor buttons during wait period
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Location: College Station, Texas
- Contact:
monitor buttons during wait period
I'm setting up a sequence where an image is shown on the screen, and then it waits for a preset number of seconds.
The viewer is to click one of a set of buttons during this period and at the end of the wait time the button choice is recorded and a new sequence begun.
The problem is that using a repeat function or wait prevents Revolution from monitoring or responding to the button clicks.
I don't want to stop the wait period, just monitor the button activity during it.
I've done some complex things in Revolution but this baffles me as it doesn't seem like it should be a problem.
Am I looking at it the wrong way or something?
Thanks in advance,
The viewer is to click one of a set of buttons during this period and at the end of the wait time the button choice is recorded and a new sequence begun.
The problem is that using a repeat function or wait prevents Revolution from monitoring or responding to the button clicks.
I don't want to stop the wait period, just monitor the button activity during it.
I've done some complex things in Revolution but this baffles me as it doesn't seem like it should be a problem.
Am I looking at it the wrong way or something?
Thanks in advance,
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Location: College Station, Texas
- Contact:
-
- Posts: 9
- Joined: Sat Apr 08, 2006 3:54 pm
you can also use
the clicked btn can be recorded by a global or a costum property. for example (code of a btn):
and once again the nextimage code:
hmmmm,.. i hope it is useful for you,..
SEIDL.
Code: Select all
on nextimage
## here you can display your new pic
send "nextimage" to me in 5 sec
end nextimage
Code: Select all
global clickedbtn
on mouseup
if the clickedbtn is empty then ## an other btn has been klicked alreadey
## you have to empty this global in your nextimage handler
put the name of me into clickedbtn
else
beep
end if
end mouseup
Code: Select all
global clickedbtn
on nextimage
## here you can display your new pic
put clickedbtn & cr before fld "btnlist"
put empty into clickedbtn ##
send "nextimage" to me in 5 sec
end nextimage
SEIDL.
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Location: College Station, Texas
- Contact:
This is the basic function that I am using; the viewer makes choices during the 10 second interval by clicking buttons.
The problem was being able to monitor the buttons while this was running.
The 'send CheckIt to me' was the means of repeating the sequence, but the critical factor is the 'in 1 second'.
I did not have that part there before so there was no time opening to watch the buttons. Now it watches during each 1 second interval and works fine.
The problem was being able to monitor the buttons while this was running.
The 'send CheckIt to me' was the means of repeating the sequence, but the critical factor is the 'in 1 second'.
I did not have that part there before so there was no time opening to watch the buttons. Now it watches during each 1 second interval and works fine.
Code: Select all
on CheckIt2
Global start, ChoiceS
put the seconds - start
if the seconds - start < 10 then send CheckIt2 to me in 1 second
else
put ChoiceS & return after field "choices" -- records viewer's choices
end if
end CheckIt2
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Location: Aalst, Belgium
- Contact:
Alternately, you can store the messageID that is put into 'the result' when you use a 'send in time' construct, and 'cancel' that when someone picks a choice.
So you would have something like this in the card script.
Then, when the user makes a choice (presumably by clicking a button or an image), make sure its script calls the 'FinishWithAnswer' handler to prevent the 'out of time' scenario.
With such a system, your app stays responsive -- you can add a second timer construct to update a field with a text like 'N seconds left', retain its messageID in another script local variable, and cancel that from the FinishWithAnswer handler in one go.
Hope this helped,
Jan Schenkel.
So you would have something like this in the card script.
Code: Select all
local sMessageID
on StartQuestion
-- setup everything for the next question
-- ...
-- now fire off the timer and save the messageID
send "FinishWithoutAnswer" to me in 10 seconds
put the result into sMessageID
end StartQuestion
on FinishWithoutAnswer
-- clean up the messageID, just to be on the safe side
put empty into sMessageID
-- show the user some 'out of time' message
-- ...
end FinishWithoutAnswer
on FinishWithAnswer
-- make sure we don't see the 'out of time' message
if sMessagerID is not empty then
cancel sMessageID
put empty into sMessageID
end if
-- show the user if their choice was right
-- ...
end FinishWithAnswer
With such a system, your app stays responsive -- you can add a second timer construct to update a field with a text like 'N seconds left', retain its messageID in another script local variable, and cancel that from the FinishWithAnswer handler in one go.
Hope this helped,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Location: College Station, Texas
- Contact:
Looks good
OK, I'll give that a try. The "cancel sMessageID" is new to me, but the rest makes sense. Thanks.
For more information about the cancel command, you might want to read the docs for cancel and pendingMessages.
The id number used by cancel is the first item of a line of the pendingMessages.
Best,
Mark
The id number used by cancel is the first item of a line of the pendingMessages.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode