Hit Test Issues/Response collection conversion
Kyle Davis
kylehdavis at gmail.com
Fri Oct 21 01:15:33 UTC 2011
Hello,
I am new to programming beyond some experience with R so the learning
curve has been a bit steep thus far. The program I am currently
working on is a number line experiment where subjects are shown a
number and a line that has the endpoints labeled (i.e. 0 to 1000, -5
to 5, etc.). I am having two problems with it though. The first
problem is I am trying to create an error trap where if the subject
clicks outside of the line it returns them an error message and then
back to the same exact problem they were working on when the error
occurred. PST support suggested creating a label called "tryagain"
and then returning the user to that but it did not work the way I
intended. I want to do a HitTest where if the user clicks within the
slide object "LineText" it collects there response and they go on but
if they click outside of the object it returns an error message, I am
just not sure of the syntax and the functions I need to call in order
to present the error message.
The second problem is with calculating the user input. The
existing code was programmed by someone else and it works fine if the
origin of the line is 0, but if the origin of the line is anything
else (i.e. -5, .1, 15) it merely reports the users response on the
scale of the difference between the origin of the line and the
endpoint (so a scale of 15 to 25 where the user clicks where 20 should
be it is reported as 5 instead of 20).
Below is the code that is giving me the problems... sorry if it is
messy.
Dim lineOrigin as Integer, lineEnd as Integer
Dim lineDispOrigin as Integer, lineDispEnd as Integer
Dim xInt as Integer
Dim slText as SlideText
Dim scalePerPixel as Double
'Retrieve mouse click location and store in Point variable to send to
PointInRect
Dim theMouseResponseData As MouseResponseData
Dim ptr As Point
Dim strHit As String
'Set theMouseResponseData =
CMouseResponseData(StimulusSlide.InputMasks.Responses(1))
Set theMouseResponseData =
CMouseResponseData(Stimulus.InputMasks.Responses(1))
ptr.x = theMouseResponseData.CursorX
ptr.y = theMouseResponseData.CursorY
lineOrigin = c.GetAttrib("LineOrigin")
lineEnd = c.GetAttrib("LineEnd")
Set slText =
CSlideText( StimulusSlide.States("Default").Objects("LineText") )
'? msgbox slText.X & " " & slText.Width '?
' assume line is centered, so slText.X = Display.XRes/2
'? msgbox slText.Width & " " & Left$( slText.Width,
(Len(slText.Width) - 1) ) '?
xInt = CInt( Left$( slText.Width, (Len(slText.Width) - 1) ) ) '
remove "%" from end
xInt = xInt * Display.XRes / 100 ' convert % to #pixels
lineDispOrigin = (Display.XRes/2) - (xInt/2)
'? lineDispEnd = slText.X + (slText.Width/2) '?
lineDispEnd = lineDispOrigin + xInt
scalePerPixel = (LineEnd - LineOrigin) / (LineDispEnd -
LineDispOrigin)
c.SetAttrib "Line.CursorX", ptr.x
c.SetAttrib "Line.XUniform", (ptr.x - lineDispOrigin) * scalePerPixel
'?Figuring out the definitions of variables'?
c.SetAttrib "LineDispOrigin", lineDispOrigin
c.SetAttrib "LineDispEnd", LineDispEnd
c.SetAttrib "scaleperpixel", scalePerPixel
c.SetAttrib "xInt", xInt
'Hit Test'
If strHit <> "LineText" Then
Goto TryAgain
End If
'If strHit = "LineText" Then
'Results.Text = "Great!"
'Stimulus.ACC = 1
'Else
'Results.Text = "You missed, try again!"
'Stimulus.ACC = 0
'End If
Set slText = Nothing
Set theMouseResponseData = Nothing
Mouse.ShowCursor FALSE
Thank you for any help, I really appreciate it as I need to get this
up and running soon.
p.s. PST recommended "To calculate responses, I strongly recommend
adjusting the X position of the response according to the left edge of
the line (i.e. Display.XRes * .3 for your 70% line), then calculating
the rating as a percentage of the total length of the line
(Display.XRes * .7). All of these calculations should be done in terms
of pixels, and adjusted at the end to fit your scale if desired." but
I am not exactly sure how to implement this as I did not create the
original calculation. Thank you again
--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To post to this group, send email to e-prime at googlegroups.com.
To unsubscribe from this group, send email to e-prime+unsubscribe at googlegroups.com.
For more options, visit this group at http://groups.google.com/group/e-prime?hl=en.
More information about the Eprime
mailing list