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

ventgroup

Composition of a group object

clip0044

 

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

 

callpopuptags

 

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:

 

tagexamplecallpopup

 

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

popupwindowcall

Popup Composition

clip0045

 

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

 

popuptags

 

 

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):

 

clip0046

callpopupudproperties

 

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):

 

callpopupcontrol

 

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":

 

popupwindowcallfirst

 

Let's write a script:

popupscript1

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):

 

popupchange

 

Let's write a script:

 

otherscriptpopup

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:

 

clip0047

popupscriptcollection

 

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:

 

callpopupcomplex

 

You can download this project here.