Extra practice
More dependencies
Often, with attribute-from-script connections, scripts use the attributes of one or more parts. Because changes in those attributes could affect the answer that the script returns, the script has a dependency on each attribute that it references. VA Smalltalk runs the script whenever there is a change in one of the attributes to which it is connected.
If you would like to run the script more often, you can add more dependencies to the ones that VA Smalltalk already knows about. Let's try it. First create an attribute-from-script connection from the list's items attribute to your beep script and then select Test iconto test your part. You should hear a beep when the window opens as the items attribute is set to the contents of the current working directory. Each time the items attribute changes the beep script executes.
Now, close your test window and go back the the Composition Editor. Open the Attribute-from-script connection -- Settings window for the attribute-from-script connection you just created and select More dependencies. The Attribute-from-script connection Dependencies window opens and looks like the following:
Attribute-from-script connection Dependencies window
Select Multi-line Edit1 from the Select part list and then select object from the Select attribute list. Select Add row and then select OK. Select OK in the Attribute-from-script connection - Settings window.
Save your part and select Test iconto test it. You should hear a beep when the window opens. You will also hear a beep whenever you open a different file and the multi-line edit part's object attribute changes.
Last modified date: 03/13/2020