Complex call popup with scripts

<< Click to Display Table of Contents >>

Navigation:  Examples > Call popup >

Complex call popup with scripts

Previous pageReturn to chapter overviewNext page

Suppose we have several objects of the same type on the screen, each object has several parameters. When we click on an object, we want to see a popup window with information about the state (value) of the tags and be able to set values for some tags directly in the pop-up window.


1. Let's create a complex group object, let's call it VE01, which consists of primitive objects - Rectangle, Ellipse, Polygon, Image, Text/EditField and on top of these objects we placed a transparent Button - CallPopup:


Image of the finished object


Composition of a group object



2. Let’s create tags and bind them to objects from the group:




To make it easier to scale this project and be able to quickly copy this group of tags to the next similar object, we associated the name of the tags with the group using the {group} keyword. Example:




3. We want to call a popup screen by clicking on this group object (by clicking on the transparent button - CallPopup, to be precise) and display all the properties in the corresponding fields.


Let's create a popup window named FbMotorAOVentil (to do this you need to create a new screen and specify the screen type - "Pop-up"), which is also a group object.


Popup window


Popup Composition



4. Let's create tags for this pop-up window:





5. In order to have possibility to send some information from the group object to the pop-up window, let’s create user-defined properties (we set user-defined properties for the “Button” object, which causes the pop-up window):





6. Now, let’s configure the pop-up window call. In the Properties of the “Button”, which causes a pop-up window in the “Control” tab, in the “Commands and Arguments” field we will pass the arguments (which we set as user-defined properties in the paragraph above):




7. Now let's create a script that will use the arguments that we wrote down in the paragraph above and which will be used when opening our popup window. Create a script called CallPopup with type "Screen" in ST language and execution "onOpen":




Let's write a script:


After you have recorded the script, be sure to launch it by clicking the button on the toolbar: runsimulation


8. Let's create another script to pass changes in the pop-up tags to the tags of the group object (if we change the tag value in the pop-up window, then it will be transferred to the object tag), and vice versa, to catch changes in the tag value of the group object and set the value of the pop-ups tags (if the value of an object's tag changes while the popup is open, the value in the popup will also change):




Let's write a script:



After you have recorded the script, be sure to launch it by clicking the button on the toolbar: runsimulation


9. Let’s bind the scripts to our pop-up window:





10. So, we have created a pop-up window (One for all objects), into which the tag values are transferred and from which you can change the tag values for the object. We also configured the group object VE01 using custom properties. Now let's duplicate the object as many times as we need and change the values in the custom properties.

11. Let's Run simulation to check the settings:




You can download this project here.