Setting up the Popup Window
- Right click on a folder in the Project Browser and select Popup Window to create a new popup.
- Drag a Compressor image from Symbol Factory.
- Drag a Label component from the component palette to your window.
Create a custom property on your popup window that will receive the passed parameters. Right click on your window and select Customizers > Custom Properties. The Custom Properties window is displayed.
- Click the Add icon to add a property.
Specify a Name for the Custom Property, such as compNum, and click OK.
The custom property is created and displayed in blue at the bottom of the Property Editor.
Do not bind these custom properties to anything, leave them unbound so you can pass values into them without any other values to override them.
Let's use an expression on the Label to show what compressor number we are on.
- Select the Label and click the binding icon for the Text property.
- Select Expression for the binding type.
- Click the Insert Property Value icon in the Expression window and choose the compNum custom property on the root container for the compressor popup window as shown in the image below.
We want the word "Compressor" to appear before the number in the label. Update the Expression as follows.
The expression should look as follows in the Property Binding window.
- Click OK to save the binding.
Setting up the Main Window
- In a Main Window (parent window) drag a Button from the component palette to your window. Type "Compressor 1" into the text property.
- Add a script to the button which opens the popup that we created earlier. We can then pass in a value to designate that this button should be opening Compressor 1.
- Right click on the Compressor 1 button and select Scripting.
- Under Event Handlers, select actionPerformed.
- Click the Open / Swap radio button.
- Under Window, use the dropdown list to select the path to your Popup Window (i.e.,Popup_Param_Test).
- Check the Pass Parameters check box, and click the Add icon to add a parameter.
Click the new row under Parameter Name and a dropdown list will appear. Select the custom property compNum.
Ignition will automatically check the Root Container of the window selected in the Window dropdown. If you do not see the compNum parameter, it may have been created on wrong component, so check the Root Container of the Compressor Popup window.
- Enter "1" in the Value column because the button will be for Compressor 1.
- Click OK to save the script.
- Now, create a second compressor button. A quick way to do this is duplicate (Ctrl D) the Compressor 1 button so it inherits the script. Update the Text property to Compressor 2.
- Right click on the new Button component and select Scripting. Update the parameter Value being passed in from a 1 to a 2.
- Click OK to save the script.
- Test it out by putting the Designer in Preview Mode. Click one of the Compressor buttons, then navigate back and click the other Compressor button. While these buttons are opening the same popup, they display different information because they are using the parameter that we passed in for indirection. In this example, we just used a label, but the parameters can be used in things like indirect Tag bindings or scripts to pull in various Tag bindings.