DoHitTest - Multiple Mouse Clicks and feedback
ryan8806
ryansouthgate8806 at googlemail.com
Thu May 20 18:02:29 UTC 2010
hello guys,
i'm new to e-prime, but not new to programming.
i've got a slight problem, i've read the following post about multiple
mouse clicks
however i've become a bit unsure about the whole "slide states"
scenario. for my experiment i'm having the following screen:
on this screen i want to be able to detect 4 mouse clicks in total,
each mouse click will be assigned to any box, but not the same box
twice. i was wondering if there is an easily programmable way to
change the colour of each selected box once it has been clicked, i've
currently only been able to do this with only one box. in the boxes i
would also like the numbers 1-4 displayed according to which one was
clicked 1st, 2nd, 3rd etc. i am more than happy with the underlying
code about setting up the arrays and checking those as i have had
years of experience in that, however it is the detecting and
displaying i'm unsure about.
another question is am i able to do this all from the e-prime user
interface using the "slides" and "inline" functions or would i have to
do it entirely from the script editor?
here is my current code if this helps:
[code]'Designate "theState" as the Default Slide State, which is the
'current ActiveState on the Slide object "PRACquestion".
Dim theState As SlideState
Dim theState2 As SlideState
Set theState = PRACquestion.States("Default")
Set theState2 = PRACquestion.States("Default")
Dim theSlideText As SlideText
Dim theSlideText2 As SlideText
Dim strHit As String
Dim strHit2 As String
Dim intRating As Integer
Dim intRating2 As Integer
Dim i as Integer
'0 is correct 1 is incorrect
Dim inputArray (3) as Integer
Dim arrayCount as Integer
Dim numberCorrect as Integer
Dim loopCount as Integer
loopCount = 1
arrayCount = 0
Loop_Start:
'Was there a response?
If PRACquestion.InputMasks.Responses.Count > 0 Then
Dim theMouseResponseData As MouseResponseData
'Get the mouse response.
Set theMouseResponseData =
CMouseResponseData(PRACquestion.InputMasks.Responses(1))
'Determine string name of SlideText object at
'mouse click coordinates. Assign that value to strHit
strHit = theState.HitTest(theMouseResponseData.CursorX,
theMouseResponseData.CursorY)
'Did the subject click one of the SlideText sub-objects?
If strHit <> "" And strHit <> "Question" Then
'Gain access to the SlideText sub-object selected
'Change appearance of selected sub-object to provide feedback to the
subject.
Set theSlideText =
CSlideText(PRACquestion.States.Item("Default").Objects(strHit))
theSlideText.BackColor = CColor("red")
theSlideText.Text = 1
'Redraw the Slide to present changes
PRACquestion.Draw
'Each SlideText is named "Text" followed by a single digit. The Mid
function is
'instructed to return the 5th character (i.e. the digit) of strHit for
logging purposes.
intRating = CInt(Mid(strHit, 5, 1))
if intRating = 1 then
inputArray(0) = 0
else
inputArray(0) = 1
end if
'Log rating in the data file under the attribute "Rating"
'c.SetAttrib "Rating", intRating
Sleep 1000
theSlideText.BackColor = CColor("green")
'The subject did not click a valid sub-object.
Else
'c.SetAttrib "Rating", "nothing"
'MsgBox "Please Select a Valid Option", ,"ATTENTION!"
'set theMouseResponseData = nothing
'goTo Loop_Start
End If
'The subject did not respond.
Else
'c.SetAttrib "Rating", "nothing"
End If
'Was there a response?
'If PRACquestion.InputMasks.Responses.Count > 2 Then
Dim theMouseResponseData2 As MouseResponseData
'Get the mouse response.
Set theMouseResponseData2 =
CMouseResponseData(PRACquestion.InputMasks.Responses(1))
'Determine string name of SlideText object at
'mouse click coordinates. Assign that value to strHit
strHit2 = theState2.HitTest(theMouseResponseData2.CursorX,
theMouseResponseData2.CursorY)
'Did the subject click one of the SlideText sub-objects?
If strHit2 <> "" And strHit2 <> "Question" Then
'Gain access to the SlideText sub-object selected
'Change appearance of selected sub-object to provide feedback to the
subject.
Set theSlideText2 =
CSlideText(PRACquestion.States.Item("Default").Objects(strHit2))
theSlideText2.BackColor = CColor("red")
theSlideText2.Text = 2
'Redraw the Slide to present changes
PRACquestion.Draw
'Each SlideText is named "Text" followed by a single digit. The Mid
function is
'instructed to return the 5th character (i.e. the digit) of strHit for
logging purposes.
intRating2 = CInt(Mid(strHit2, 5, 1))
if intRating2 = 2 then
inputArray(1) = 0
else
inputArray(1) = 1
end if
'Log rating in the data file under the attribute "Rating"
'c.SetAttrib "Rating", intRating
Sleep 1000
theSlideText2.BackColor = CColor("green")
'The subject did not click a valid sub-object.
'Else
'c.SetAttrib "Rating", "nothing"
'MsgBox "Please Select a Valid Option", ,"ATTENTION!"
'set theMouseResponseData = nothing
'goTo Loop_Start
'End If
'The subject did not respond.
'Else
'goTo Loop_Start
'c.SetAttrib "Rating", "nothing"
End If
numberCorrect = 0
for i = 0 to 3
if inputArray(i) = 0
then
numberCorrect = numberCorrect + 1
end if
next i
c.SetAttrib "numberCorrect", numberCorrect
Set
theMouseResponseData = Nothing
Mouse.ShowCursor FALSE[/code]
thanks in advance
ryan
--
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