Changing image position according to xy-coordinates from mouseclicks

1,189 views
Skip to first unread message

Johannes Bjerva

unread,
Jun 18, 2012, 3:53:18 PM6/18/12
to e-p...@googlegroups.com
Hello,

I am currently developing an experiment in which the participants will click an area of the screen, following which an image should appear in that location.

What I have tried so far is having a slide object containing an image object. In the image object's sub-property pages I've tried to set the X and Y positions to the attributes "[PicPosX]" and
"[PicPosY]". However, once I click apply, E-Prime automatically changes this to "[PicPosX]:center" and "[PicPosY]:center".

In order to get the coordinates themselves, I have added this inline-code after the slide object:
Dim theMouseResponseData As MouseResponseData
Set theMouseResponseData = CMouseResponseData(Slide1.InputMasks.Responses(1))
c.SetAttrib "PicPosX", theMouseResponseData.CursorX
c.SetAttrib "PicPosY", theMouseResponseData.CursorY 

Obtaining the coordinates and setting the attributes seems to work perfectly, since I can see the coordinates in the resulting data files.
However, the image does not change positions, but remains in the center (most likely due to E-Prime's :center-addition to my attributes).

Any help in solving this problem would, of course, be greatly appreciated.

Kind regards,
Johannes Bjerva

Johannes Bjerva

unread,
Jun 19, 2012, 3:48:41 AM6/19/12
to e-p...@googlegroups.com
I managed to solve the problem through using a global variable, which is set by the mouse coordinates, rather than an attribute.
That is to say, the problem was not in the automatic addition of ":center", as I first assumed.

Problem solved! :)

David McFarlane

unread,
Jun 19, 2012, 11:01:18 AM6/19/12
to e-p...@googlegroups.com
Johannes,

Glad you sorted it out. Just a bit of explanation about the
":center", that happens when you use an attribute reference (e.g.,
[x]) for an X or Y Posiiton, and I do not think that PST explains
this anywhere. Think about it -- When you use an attribute
reference, EP does not know until run time what position to use. But
during design time, it still has to place the object at some example
position. Where should it put the object during design time? The
":center" merely indicates where the object will appear on the
*design* surface, and then the object will move to the referred
position at *run* time.

And if you like, you could replace ":center" with a position of your
choice. E.g., "[x]:25%" would place the object 25% from the left of
the design surface during design time, while "[x]:150" would place
the object 150 pixels from the left during design time, and in each
case would place the object at the value of [x] at run time. Does
that clarify things?

---------------
David McFarlane
E-Prime training
online: http://psychology.msu.edu/Workshops_Courses/eprime.aspx
Twitter: @EPrimeMaster (twitter.com/EPrimeMaster)
---------------

Stock reminder: 1) I do not work for PST. 2) PST's trained staff
take any and all questions at
http://support.pstnet.com/e%2Dprime/support/login.asp , and they
strive to respond to all requests in 24-48 hours -- this is pretty
much their substitute for proper documentation, so make full use of
it. 3) In addition, PST takes questions at their Facebook page
(http://www.facebook.com/pages/Psychology-Software-Tools-Inc/241802160683
), and offers several instructional videos there and on their YouTube
channel (http://www.youtube.com/user/PSTNET ) (no Twitter feed yet,
though). 4) If you do get an answer from PST staff, please extend
the courtesy of posting their reply back here for the sake of others.

Johannes Bjerva

unread,
Jun 19, 2012, 11:26:05 AM6/19/12
to e-p...@googlegroups.com
David,

That makes a lot of sense!
Thanks for the tip.

Johannes

Ram Kalendarev

unread,
Feb 26, 2014, 9:00:45 AM2/26/14
to e-p...@googlegroups.com
Hi! 

I've managed to encounter the same problem!

can you please specify your solution?

Thanks!

agata.b...@gmail.com

unread,
Nov 15, 2016, 11:32:51 AM11/15/16
to E-Prime
I am also working on a similar issue, could you specify how you defined your global variables? Don't PosX and PoxY still have to be attributes so that you can use them when specifying the position of your image in the image properties? (X: [PosX], Y: [PosY]).

Best
Agata
Reply all
Reply to author
Forward
0 new messages