The Drawing Area Screen Component allows users to create freehand drawings on touchscreen devices; on devices that do not support touchscreen technology a mouse can be used.
Note: The Drawing Area Screen Component is only available when the Drawing Area Component extension is installed.
The example referred to in this article is a simple Process that consists of two Screens:
- The first Screen displays the Drawing Area, allowing the user to create a freehand drawing.
- The second Screen displays the freehand drawing from the previous step as an image.
Perform the following actions on the first Screen of the Process:
- Drag and drop a Drawing Area Screen Component from the Component Library to the Screen editor.
Note: If the Drawing Area is not available in the Component Library, ensure that the Drawing Area Component extension is installed and started.
- Set the properties of the Drawing Area according to your requirements. You can set the Display and Canvas size, as well as specifying the stroke width and color.
- Define the variable binding for the Drawing Area. The variable should be of the type
HttpFileUpload, and should be defined globally in the Process and then inherited inside this Screen where it is bound to the Drawing Area. Use an appropriate name for the variable, e.g. $drawingArea.
Inside the browser, the the Drawing Area is rendered as a canvas HTML component which captures touches and mouse events.
When the page that contains the Drawing Area is submitted to the server, a PNG image is saved in the data home directory under work/tmp/uploads. The previously defined HttpFileUpload variable saves the image URI in its filePath field.
Open the second Screen used in your Process. After the image data has been submitted to the server in the first Screen, you can display it in this Screen as an image:
- Inherit the variable (e.g.
$drawingArea) containing the image data. - Drag and drop an Image Screen Component into the Screen.
- In the properties of the Image Screen Component, define the Type as URL and set the URL to retrieve the saved image using the following expression:
FILESYSTEMURL($drawingArea.filePath).