This article applies to:
This sample demonstrates how to use mouse tracking and Canvas commands to achieve a 'live drawing' functionality.
This sample presents 3 trials in which participants are instructed to draw, write something, or trace an image. To draw, the left mouse button is clicked and held. If using a touch screen, touching the touch screen is used as a left mouse press; releasing the touch from the screen is used as a left mouse release, resulting in a left click.
The Slide is presented with a SlideImage and 2 buttons (a blank image that matches the Slide's BackColor is used on non-image trials). An on-screen canvas is created. A "Do...While" Loop is used to detect a response from the mouse. Another "Do...While" Loop within the first one determines if the mouse's left button (or a finger on the touchscreen) is currently being held down. If so, the mouse coordinates are identified and "cnvs.LineTo" is called to draw a line from the last known mouse coordinate to the current one. Mouse coordinates are sampled every 25 ms only while the left button is held down.
In the first Loop that detects a response, the buttons are also accounted for. Clear Screen clears the canvas and redraws any Slide sub-objects. Accept terminates the Slide.
Lastly, an image of what is on screen is saved to the location where the .es/.ebs exists. This is saved in the format of "[ExperimentName]-[Subject]-[Session]-Response<CurrentSampleNumber>"
NOTE: There are differences between the E-Prime 2.0 and E-Prime 3.0 versions of this sample. E-Prime 2.0 handles the buttons using SlideText sub-objects in conjunction with the Hit Test function. For details on the Hit Test function, see Response Areas for Mouse Input . E-Prime 3.0 uses SlideButtons. Multiple InputMasks exist on the Slide - the Mouse and 2 Buttons. The first Button Input Mask handles the Clear Screen option where the Inline script identifies its Checked property and its status. The second Button Input Mask handles the Accept option and is set to terminate the Slide. Please refer to BUG: SlideButton AutoCheck and InitialCheck properties are ignored in E-Studio unless Attribute references are used . Additionally, the E-Prime 3.0 version saves the image of what is on screen by saving the Primary Canvas as opposed to the on-screen Canvas due to the following known issue: INFO: Display.Canvas.SaveImage does not include movies or buttons .
For more information about the Canvas object, please refer to the E-Prime Command Reference (https://pstnet.com/ecr).
NOTE: You may find that you have to click or touch multiple times in order for the drawing to occur. If this occurs, open the Experiment Object Properties, navigate to the Devices tab, open the Mouse Device properties and set the Open Mode to Emulate.