Mouse Click & Target Task

430 views
Skip to first unread message

Lucas Hutchison

unread,
Oct 3, 2011, 2:50:35 PM10/3/11
to E-Prime
I am working on a small experiment where I would like the following:

-Target (20 x 20 pixel red circle) appears at a random location on the
screen
-when the target is presented, the participant must click the target
-once the participant clicks, the next randomly located target will
appear (and the prior target is removed), and the process repeats for
n number of trials needed

I am able to display the targets at random locations, but I am unsure
of how to record the X and Y positions of the click and how to compare
those to the actual X and Y positions of the target to determine
accuracy. I would like to record both the response time and the click
accuracy.

I have been trying to find resources online and in the help
documentation, but much of the online code is older than my version
and some of the methods/ objects they use have been renamed.

I am using E-Prime version 2.0.8.74


Thanks for the help!

Paul Groot

unread,
Oct 3, 2011, 6:03:35 PM10/3/11
to e-p...@googlegroups.com
Hi Lucas,

After capturing a mouse click response you could immediately retrieve
the mouse position using a few lines of script:

dim ptMouse as Point
Mouse.GetCursorPos ptMouse.x, ptMouse.y

To determine if this point is inside the drawn circle you could use a
simple calculation: just calculate the (squared) distance between the
center of the circle and the hit point:

Const radius = 10
dim dx as long
dim dy as long
dx = ptMouse.x - center.x
dy = ptMouse.y - center.y
if (dx*dx + dy*dy)<=radius*radius then
... inside circle
else
... outside circle
end if

I'm not using a square root because it is computationally intensive
and not required because the comparison also holds for squared values.

cheers
paul

2011/10/3 Lucas Hutchison <lahu...@mtu.edu>:

> --
> You received this message because you are subscribed to the Google Groups "E-Prime" group.
> To post to this group, send email to e-p...@googlegroups.com.
> To unsubscribe from this group, send email to e-prime+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.
>
>

Lucas Hutchison

unread,
Oct 4, 2011, 12:34:19 PM10/4/11
to E-Prime
Currently I am having trouble capturing the x, y coordinates of the
mouse. I currently have something like this:


dim rtmouse as MouseResponseData

set rtmouse = CMouseResponseData(?not sure what to put in here since
the documentation i found using this had something that gave me errors
at run?)


On Oct 3, 6:03 pm, Paul Groot <pfc.gr...@gmail.com> wrote:
> Hi Lucas,
>
> After capturing a mouse click response you could immediately retrieve
> the mouse position using a few lines of script:
>
> dim ptMouse as Point
> Mouse.GetCursorPos ptMouse.x, ptMouse.y
>
> To determine if this point is inside the drawn circle you could use a
> simple calculation: just calculate the (squared) distance between the
> center of the circle and the hit point:
>
> Const radius = 10
> dim dx as long
> dim dy as long
> dx = ptMouse.x - center.x
> dy = ptMouse.y - center.y
> if (dx*dx + dy*dy)<=radius*radius then
>    ... inside circle
> else
>   ... outside circle
> end if
>
> I'm not using a square root because it is computationally intensive
> and not required because the comparison also holds for squared values.
>
> cheers
> paul
>
> 2011/10/3 Lucas Hutchison <lahut...@mtu.edu>:

David McFarlane

unread,
Oct 4, 2011, 3:32:12 PM10/4/11
to e-p...@googlegroups.com
Lucas,

Paul Groot nicely showed how to do this by using the mouse directly
instead of through an input mask. That is probably easier to do.

The method that you are working on instead uses a mouse input mask as
part of a stimulus object. That can offer some advantages, but is
much harder to use -- as you have seen, it requires wrestling with
the MouseResponseData collection. To get some idea, see the
"Response Areas for Mouse Input" and "Multiple Response Collection"
examples which you may download from the PST web site. You might
also look at the MouseResponseData topic and related topics in the
E-Basic Help facility.

-- David McFarlane, Professional Faultfinder

Reply all
Reply to author
Forward
0 new messages