Working with  controls in scripts
            Newlook supports a wide range 
 of controls that you can add to your forms with Designer. To create a 
 truly dynamic UI, scripting or macros are required to:
            
                - Handle events triggered by 
 controls, and
- Update controls
Control Naming
            To reference a control accurately in a script, it is recommended that you name the control in Designer. It is also possible to reference a control using the Form.ActiveControl object or its index in the Controls Collection, however both of these methods are less accurate than using a control's name.
            Event Handling
            Newlook controls trigger different 
 events. If you would like some custom behavior to happen as a result of 
 an event, you can have Newlook 
 call your script every time the event occurs. To connect a script to an 
 event, do the following:
            
                - Open the relevant form 
 in Designer (unless you are already 
 in Designer).
- Click on the control 
 who's event(s) you want to handle.
- Bring up the Properties 
 window for that control unless it is already up by right clicking on the 
 control and selecting Properties Window (F4).
- Scroll down to the Events 
 category and have a look at all the events available to be handled for 
 this control.
- Set the event property 
 that you wish to handle to the name of the relevant script.
- Save your override.
Step by Step Example
            This is a simple example that demonstrates the concepts of Control Naming, 
 Event Handling and using scripts to interact with controls.
            A. Create a new form and place some controls on it:
            
                - Create a 
 new form by selecting Forms | Added Forms 
 | New from the Developer Bar.
- Insert a checkbox control 
 on the form. Change the caption of the checkbox to Extended list.
- Set the OnChange property to ModifyList.
- Set the Name property  to extendedList.
- Next insert a combo box control on your form, below the checkbox.
- Set its name to Items. 
- Set its List property to A;B;C;.
- Save the form with the name Item Selection.
B. Create a script to open the form.
            Now that the form is saved, we need to create a script that 
 opens the form using the OpenForm method. 
            
                - From the Developer bar, select  Logic | Scripts, then click New.
- In the properties panel of the script editor enter the name OpenItemsForm and select JScript from the language drop down.
- Expand the Menu section and tick the option Show in the menu for smartclient users.
- In the main script editor window enter the following one line script and save the script:
                App.OpenForm ("Item Selection");
             
            C. Create the script to handle the OnChange event of the scrollbar.
            
                - Open a second new script and give it the name ModifyList. 
- Select JScript from the language drop down.
- In the main script editor window enter the following lines of code and save the script:
                if (App.ActiveForm.extendedList.Value == true)
                {
                App.ActiveForm.Items.AddItem ("D",3);
                }
                else
                {
                App.ActiveForm.Items.Clear;
                App.ActiveForm.Items.List = "A;B;C;";
                }
             
            Open the runtime client and run the OpenItemsForm script from the macro menu. The combo box list should vary between four items and three, depending on whether you have the extended items checkbox selected or not.
            
            © 
 2004-2021 looksoftware. 
 All rights reserved.