I would like to run a study where I have users scroll down to click a target in an image (that I have already created). I want the images to be the width of the screen, and I want users to scroll down like you would on a website or word doc.
Is it possible to enable scrolling? If not using the GUI, then with code?
Thanks for your help!!!
Hi @Pavlov101, yes, you can use the mouse method
getWheelRel - see docs to set the Y position of your image, or shape. Add a code component, and in the
Each Frame tab:
# Each Frame
newY = (mouse.getWheelRel() / 100)
polygon.pos += (0, newY) # where polygon is your shape
Here is an example
mouseWheel.psyexp (6.8 KB)
Awesome! Thank you so much for your help!!!
If anyone is trying to get this working online, the auto py > js translation doesn’t work (at least on v2020.2.2).
A more ‘spelled out’ version does work though-- add this in Every Frame for JS:
oldY = polygon.pos;
deltaY = (mouse.getWheelRel() * 3);
newY = (oldY + deltaY);
polygon.pos = [0, newY];
I found that while dividing by 100 locally produced a scroll at a reasonable speed, online it barely moved, and I get a more reasonable online scroll-speed multiplying by 3 instead.