This sample demonstrates how to implement a drag and drop feature. A sequence of colored boxes is presented to the subject in random order. The subject is then asked to reproduce the sequence by dragging the colored boxes to the locations in which they were originally presented.
The PresentOrder object presents three colored "boxes." Each
box's color is selected randomly from the ColorList. The Stimulus
presents three "goal boxes" in the same position, along with three
"drag" boxes, each representing one color from the sequence.
When the subject presses the left mouse button, the Stimulus
object is terminated, and a Hit Test is performed to determine which
sub-object from the Stimulus was clicked. If the subject clicks the
"termination" sub-object, the trial ends. Otherwise, the
CollectRelease object runs. This object has a Duration property of
0 and a response TimeLimit property of (infinite), allowing the script
contained in the MoveObjects InLine to execute immediately while
the CollectRelease object is still collecting the response. If the
subject clicked on one of the "drag" objects, the MoveObjects
script will execute until a left mouse button release is collected by
the CollectReleaseobject. The program then jumps to the RedoTrial
Label, and subject can click response again.
Once the "termination" area is clicked, the CheckAccuracy InLine
checks the borders of each "drag" object to see if they are within
any of the "goal" objects. If so, the color of the "drag" object is
logged in the corresponding attribute and the accuracy is assessed.
If all three "drag" objects are within the appropriate "goal" object,
the trial is evaluated as "correct."