Configuring User Inputs for Visualization Elements
All base elements and some common controls have the Input configuration property. This is where you can configure a user input for an element. For this purpose, you select an input event and an input action.
Configuring User Inputs
Requirement: A project with a visualization is open.
Open the visualization and add a Button element.
The Properties view opens for the new button.
Configure the Text property with
Number of clicks: %i
.In the application, in the
PLC_PRG
POU, declare a variable:iClicks : INT;
.Configure the Text variable property of the button as
PLC_PRG.iClicks
.At runtime, its variable value will replace the placeholder in the Text property.
In the Input configuration property, click the Configure button in the
OnMouseClick
line.Select the
Execute ST code
action from the list of possible actions and click thesymbol.
The action appears in the list of actions to be executed. The blank implementation of the action appears in the window area to the right of the list.
Program the action in the editor at Execute ST code:
PLC_PRG.iClicks := PLC_PRG.iClicks + 1;
Click OK to exit the dialog.
The user input is configured.
Compile, download, and start the application.
The application runs. The visualization opens. When the user clicks the button, the action is executed, the variable
PLC_PRG.iClicks
is incremented, and the number of clicks is printed.