record mouse only when clicked

David McFarlane mcfarla9 at msu.edu
Tue Mar 11 16:39:21 UTC 2014


Jeremy,

Greetings!  I remember you from your time here at 
MSU.  Just a few quick thoughts now to maybe get you started...

First, since you have some of this working, I 
assume that you have your preceding 
CollectResponse object set to Duration = 0 or to 
PreRelease = "(same as duration)" (or both) so 
that your code will run during the 
CollectResponse stimulus -- I mention this for 
anyone else who may tune in later.

Second, nice use of

     Do While CollectResponse.InputMasks.IsPending()

to run the loop until you get a keyboard 
response.  And thanks for using a named Const for 
the sampling interval (nInterval), you know how I 
hate "magic numbers" in the code!

Now on to your question...

Look at the MouseDevice.Buttons topic in the 
E-Basic Help facility.  That will tell you the 
current state of the mouse buttons, and works 
without an input mask (the mouse device is 
special in that regard, most input Devices 
require an input mask).  If you want the state 
only of the left mouse button, then you will have 
apply a mask for your test, thus,

     If (Mouse.GetButtons and ebMouseButton1) ...

I think you can take it from there.

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

/----
Stock reminder:  1) I do not work for PST.  2) 
PST's trained staff take any and all questions at 
https://support.pstnet.com , and they strive to 
respond to all requests in 24-48 hours, so make 
full use of it.  3) In addition, PST offers 
several instructional videos on their YouTube 
channel (http://www.youtube.com/user/PSTNET 
).  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.
\----


At 3/11/2014 12:06 PM Tuesday, Jeremy Purcell wrote:
>Iâ EURO (tm)m attempting to record/display mouse 
>movements ONLY when the mouse is clicked, but am 
>having a difficult time figuring out how to go 
>about it. Below is the inline code that I am 
>starting with. Where the â EURO oeCollectResponseâ EURO  
>is the name of the text object that is waiting for a response in a trial.
>
>
>
>It would be ideal to not have the mouse click 
>advance this inline code; so right now the only 
>way to get this code to work is by setting the 
>inputs to â EURO oeCollectResponseâ EURO  to the keyboard 
>(not the mouse). So it waits for the input to a 
>keyboard input and then it stops recording. This 
>is greatâ EURO |i.e. I want the keyboard to quite the 
>trial... but the problem is that it wonâ EURO (tm)t record 
>the mouse clicks this way.  It will only let me 
>record the position regardless of whether mouse 
>is clicked or not. And so I am having difficulty 
>figuring out how to make a conditional statement 
>where it only records/displays the mouse 
>movements IF the â EURO oeLeftâ EURO  mouse button is pressed.
>
>
>
>So, are there any ideas regarding how to record 
>ONLY when the â EURO oeLeftâ EURO  mouse button is clicked?
>
>
>
>I understand that this might be a bit of a 
>novice question, and so at least being pointed 
>in the right direction would be very helpful. 
>I've attached a very basic paradigm with only 
>two trials to illustrate the point where I am at 
>(i.e. right now it records mouse movements 
>whether the mouse key is pressed or not); oh and 
>btw it is eprime professional  2.0.10.242.
>
>
>Thank you so much for any input!
>
>
>
>  'Inline code that I have been working with
>
>
>
>'Set filename
>
>Dim strFilename As String
>
>
>
>'Declare pointer variable to hold coordinates
>
>Dim ptMouse As Point
>
>
>
>'Declare and initialize a variable that will hold the next target time
>
>' to log a coordinate
>
>Dim nLogTime As Long
>
>nLogTime = Clock.Read
>
>
>
>'Constant holding the size of the circles used
>
>' to replay the subject's path
>
>Const nRadius As Integer = 5
>
>
>
>'Create and initialize Canvas
>
>Dim cnvsReplay As Canvas
>
>Set cnvsReplay = Display.Canvas
>
>
>
>'Constant representing the interval at which coordinates will be tracked
>
>Const nInterval As Integer = 10
>
>
>
>'Counter variable used to name attributes
>
>Dim nCount As Long
>
>
>
>cnvsReplay.PenColor = CColor("black")
>
>cnvsReplay.FillColor = CColor("black")
>
>cnvsReplay.PenWidth = 1
>
>
>
>'Loop until a response is made
>
>Do While CollectResponse.InputMasks.IsPending()
>
>
>
>       'Check if 25ms have passed
>
>       If Clock.Read > nLogTime Then
>
>
>
>             'Increment counter
>
>             nCount = nCount + 1
>
>
>
>                   Mouse.GetCursorPos ptMouse.x, ptMouse.y
>
>                   cnvsReplay.Circle ptMouse.x, ptMouse.y, nRadius
>
>                   c.SetAttrib "XYTracked" & 
> nCount, (nCount & "," & Clock.Read & "," & ptMouse.x & "," & ptmouse.y)
>
>                   Sleep nInterval
>
>
>
>       End If
>
>Loop
>
>
>
>
>
>Dim strbmp As String
>
>strbmp$ = strFilename & ".bmp"
>
>Display.Canvas.SaveImage strbmp

-- 
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe at googlegroups.com.
To post to this group, send email to e-prime at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/531f3c45.0552320a.13ad.ffff8713SMTPIN_ADDED_MISSING%40gmr-mx.google.com.
For more options, visit https://groups.google.com/d/optout.



More information about the Eprime mailing list