Attribute-to-script connection example
In this example, the contents of two text entry fields,
First name and
Last name, are concatenated and placed in a third text entry field,
Full name.
Steps for creating this example
1. Build the user interface shown here.
Use the Change name choice on the pop-up menus of the entry fields to change their names to First Name, Last Name, and Full Name.
2. Open the Script Editor window by selecting
icon in the lower-right corner of the Composition Editor.
3. Use the Script Editor to create and save the following method:
concatenateNames
| firstName lastName |
firstName := (self subpartNamed: 'First Name') string.
lastName := (self subpartNamed: 'Last Name') string.
^firstName, ' ', lastName.
4. Open the Composition Editor by selecting
icon in the lower-right corner of the Script Editor.
5. Start the attribute-from-script connection. From the pop-up menu of the Full Name text entry field Select Connect then AllFeatures.... From the Start connection from dialog, do the following:
a. Specify the string attribute of the Full Name field.
b. Select OK.
6. Finish the attribute-from-script connection. Click on the free-form surface; then select Attribute from Script. A dialog will open.
From the dialog do the following:
a. Specify the concatenateNames method.
b. Because this is a attribute-from-script connection, itis necessary to sepcify dependencies, i.e. to specify additional situations that will cause the connection to update the value of the attribute. to do this, click on More Dependencies... button. A second dialog will open.
In the dialog,
1. Select the string attribute of the First Name part and click Add Row.
2. Select the string attribute of the Last Name part and click Add Row.
3. Dismiss the dialog with OK.
c. Dismiss the settings view with OK.
d. Select OK.
The connection appears as a line connecting the Full Name text field and an icon representing the script.
The string attribute of the Full Name text entry takes value based upon the script that combines the values of the other two entry fields. Whenever either of the source string attributes changes in value, the script runs again, updating the contents of the Full Name field.
Last modified date: 02/28/2018