Code component for click and drag responses

OS Mac Catalina 10.15.6
PsychoPy version 2020.2.3:
Standard Standalone? (y) Yes

What are you trying to achieve?:

I am aiming to create an experiment that allows participants to drag and drop a net stimulus (image) into the perceived coin (circle polygon) location.

What did you try to make it work?:

I used a similar discourse thread to work on a code component in builder:

This is the code I used to get a click and drag component for my image (adapted from Oli’s reply in order to refer to my image)

#Begin routine
``dynPos = (0,0) # dynamic position variable

#Each frame
while mouse.isPressedIn(netImage): dynPos = mouse.getPos()
Net3

What specifically went wrong when you tried that?:

2020-09-04 10:02:33.429 python[99773:1934702] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)
Traceback (most recent call last):
File “/Users/lucymckeown/Documents/coinExperiment/showCoin_lastrun.py”, line 230, in
if obj.contains(mouse):
AttributeError: ‘str’ object has no attribute ‘contains’

Experiment ended.

The experiment runs through and the the mouse co-ordinates are achieved but with no click and drag functionality

Please see my experiment file and conditions file attached (Net3.png is the image)
.

Hi Lucy,

Another useful starting point might be to try adapting the demo under demos>dragAndDrop ? :slight_smile: this should do what you want after a bit of editing.

Becca

Thank you I will give that a try- thanks very much :slight_smile: