Configuring Text Input
A visualization is usually configured so that it calls a virtual keyboard for a text input event when an input device is not available. For this purpose, the Write Variable follow-up action is preset accordingly in the user input: The value Standard is selected for the Input type setting.
For example, controllers which are employed as CODESYS TargetVisu often do not have a keyboard. A visualization calls a virtual keyboard. In contrast, it usually has a keyboard. A user uses a keyboard to specify the text.
However, you can also especially configure how text is input. For this purpose, more input types are available in the user input, such as Text input
or the listed visualizations. These visualizations have the Numpad/Keypad visualization type and display virtual keyboards or numeric keypads.
In the Settings for Default Text Input setting of the Visualization Manager, you can preset a keyboard visualization which is called from all visualizations in the application when required. This is possible without having to customize the user inputs of the visualizations.
Configuring text input as usual
When UTF-8 encoding is enabled for the STRING
data type, texts with language-specific characters are allowed. Texts with language-specific characters, such as diacritic characters or Chinese characters, can then be specified both during input and output. You can enable UTF-8 encoding in Dialog: Project Settings: Compile options.
Requirement: A project with a visualization is open. The CODESYS TargetVisu does not have a keyboard.
Declare an input variable in the
PLC_PRG
program.VAR_INPUT stInput : STRING; END_VAR
Add a button to the visualization and select the element.
Configure the
property withText input: %s
.Configure the
property withPLC_PRG.stInput
.In the Configure.
property, clickThe Input Configuration dialog opens. The selected input event is displayed below the caption.
Select the Write Variable action.
Select the value
Standard
in Input type of the implementation of the action.The input is configured as usual.
Compile, download, and start the application as CODESYS TargetVisu.
The visualization opens.
As a visualization user, click the button.
An input field is displayed with a virtual keyboard which allows text input by means of the mouse.
Compile, download, and start the application as CODESYS WebVisu.
The visualization opens.
As a visualization user, click the button.
An input field is displayed and prompts for text input.
Configuring text input especially for virtual keyboards
Requirement: A project with a visualization is open.
Declare an input variable in the
PLC_PRG
program.VAR_INPUT stInput : STRING; END_VAR
Add a button to the visualization and select the element.
Configure the
property withText input: %s
.Configure the
property withPLC_PRG.stInput
.In the Configure.
property, clickThe Input Configuration dialog opens. The selected input event is displayed below the caption.
Select the Write Variable action.
Select the visualization
Visudialogs.Keypad
in Input type of the implementation of the action.The virtual keyboard
Visudialogs.Keypad
is selected as the input device.Compile, download, and start the application.
The visualization opens.
As a visualization user, click the button.
The virtual keyboard is displayed and allows text input by means of the mouse.
Configuring numeric input especially for virtual numeric keypads
Requirement: A project with a visualization is open.
Declare an input variable in the
PLC_PRG
program.VAR_INPUT iInput : INT; END_VAR
Open the visualization and add a Rectangle element.
Select the element in the editor.
The properties are visible in the Properties view.
Configure the
property withNumber input: %i
.Configure the
property withPLC_PRG.iInput
.In the Input configuration property, click the Configure button in the
OnMouseClick
line.The Input Configuration dialog opens. The selected input event is displayed below the caption.
There you select the
Write Variable
action from the list of possible actions and click thesymbol.
The action is displayed in the list of actions to be executed. The blank implementation of the action is displayed in the window area to the right of the list.
Select the following settings:
Input type set to
VisuDialogs.Numpad
.Choose variable to edit set to Use text output variable.
Dialog title set to
'My virtual numpad'
.Click OK to close the dialog.
The user input is configured.
Compile, download, and start the application.
The application runs. The visualization opens. When a user clicks the rectangle, the numeric keypad opens.
Defining default text input
Requirement: A project with a visualization and a user input configuration is open. For all Write Variable follow-up actions, the value Default is selected for the Input type setting.
Double-click the Visualization Manager.
On the Settings tab, in the Default Text Input group, click in the default text input to assign visualizations.
These visualizations are defined as default text input. If a display variant does not have a keyboard, then these visualizations are called without you having to adapt the user input.