card freeze until I switch to pointer, then browser mode

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
helentam
Posts: 4
Joined: Wed Oct 29, 2008 5:46 pm

card freeze until I switch to pointer, then browser mode

Post by helentam » Wed Oct 29, 2008 6:00 pm

Hi All,

I have this strange problem with revolution. On one of the cards of a stack, I am showing a stimulus to which one is to make a response by keypress (press either the "p" or "q" key, depending on what the stimulus is). When I get to the card, revolution does not seem to take in the response. By chance I worked out that if I switch to the pointer tool, then back to the browser tool, i was able to make keypresses again.

I do not think this is due to a problem with my script using keysdown as it has worked smoothly before. Can someone enlighten me on this? At the moment I'm getting around the "freezing" problem by putting in:

choose pointer tool
choose browser tool

at the beginning of my card script to circumvent this problem. Not a very elegant solution.

Thanks,

Helen

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Oct 30, 2008 12:19 pm

Hi Helen,

I think we need more info!

What ist the "stimulus" you are showing? An image? A video?
And could you please post your cardscript?

That would really help us to help you :-)


Best from germany

Klaus

helentam
Posts: 4
Joined: Wed Oct 29, 2008 5:46 pm

Post by helentam » Thu Oct 30, 2008 12:40 pm

Hi Klaus,

Yes, more info...

The "stimuli" I'm showing is simply a pair of letters, one each in separate text fields. I'm programming a psychology experiment where my participants will see these letter pairs and make yes/no judgments on them, hence they could either press one of two designated keys (yes or no) on the keyboard.

I've programmed a pretty-much identical experiment like that before on Revolution, without any problems. In that experiment, I have a card showing some words (in text fields again, no keypresses required), once the words are shown, it moves onto the next card which shows the letter pairs (keypresses required). No problems at all.

But now I'm making a very minor change in that I'm swapping the words card and letters card around. So my participants see the letter pairs first (make keypresses for those), and then it moves on to the next card (which shows the words). And somehow at the beginning, the letters card freezes unless I do the "select the pointer then browser" routine.

Hope this is a bit more clear now. Thanks for reading!

Helen

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Oct 30, 2008 1:45 pm

Hi Helen,

since there is no OBVIOUS reason for the behaviour you are experiencing, I'm afraid we still need to look at (some of) your code/card script.

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte » Thu Oct 30, 2008 3:52 pm

Hi Helen,

do you mean freeze as in spinning beach ball? If not, might it be that there is a field that grabs the focus and thus does not let your script execute?

All the best,

Malte

helentam
Posts: 4
Joined: Wed Oct 29, 2008 5:46 pm

Post by helentam » Thu Oct 30, 2008 4:42 pm

Hi Malte, Klaus,

No, it's not freezing as in spinning beachball. It just doesn't respond to keypresses.

My script (sorry about the length) for the card is this. I've also realised that my stimuli (letters) were image files afterall (sometimes i use fields but this time it was images). Sorry for the confusion. The preopencard, opencard and showframe handlers just prepares the card to show the images (letter pairs - one on the left, one on the right). This works fine. It's just not responding to any keypresses (on idle handler).


on preopencard

put empty into field debug
put 0 into framecounter

set the idlerate to 1
put 0 into keyIsPressed
put 0 into keyEnable
put 112 into pRK
put 113 into qRK

repeat with counter = 1 to 12
hide image itemlist[counter]
end repeat

hide image "cross"

end preopencard

on opencard

set the screenMouseLoc to 1279,600
put milliseconds() into epsttime
showframe

end opencard

on showframe

add 1 to framecounter

show image "cross"
wait for 250 milliseconds
hide image "cross"

wait for 25 milliseconds

set the location of image L5Ritem[(trialcounter)*25+framecounter] to 840,400
set the location of image L5Litem[(trialcounter)*25+framecounter] to 440,400
show image L5Ritem[(trialcounter)*25+framecounter]
show image L5Litem[(trialcounter)*25+framecounter]

put milliseconds() into sttime

put 1 into timerStarted

end showframe

on idle
if keyIsPressed is 0 and timerStarted is 1 then

if pRK is in the keysDown or qRK is in the keysDown then
put milliseconds() into sptime
put 0 into timerStarted
put 1 into keyIsPressed
if pRK is in the keysDown then
rightFeedback
else
leftFeedback
end if
end if
else
if the keysDown is empty then
put 0 into keyIsPressed
end if

end if

if the milliseconds > epsttime + (5*eptime) then
put 1 into keyIsPressed
repeat with counter = 1 to 12
hide image itemlist[counter]
end repeat
writeData
end if

pass idle

end idle

Klaus
Posts: 14191
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Oct 30, 2008 4:53 pm

Hi Helen,

Oh, using "idle" is a dangerous thing in Rev!
You are coming from HyperCard, right? ;-)

Check the docs for "idle" and you will read:
...
on idle -- avoid if possible
...

Try to replace "on idle/end idle/pass idle" with "on keydown/end keydown/pass keydown" in your script and see if that works better.


Best

Klaus


P.S.
I did not see any local variable declaration, but I think you just did not paste them here, right?

Post Reply