Event-to-action connections
Event-to-action connections cause an action to be performed when a certain event takes place. The default color of this connection type is green.
For event-to-action connections, the event is always the source and the action is always the target. If you try to connect an action to an event, VA Smalltalk automatically reverses the source and target for you, so the connection is an event-to-action. A simple example of an event-to-action connection follows:
• Place a Push Button part within the default Window part in the Composition Editor.
• Place a second Window part on the free-form surface of the Composition Editor.
• Connect the clicked event of the Push Button to the openWidget action of the new window part you added.
This causes a second window to display when the push button is pressed.
Attributes can also be used to trigger an action and events can be used to change the value of an attribute. This behavior is made possible because an attribute typically signals when it is changed. As a result, you can make the following connections with attributes:
Connecting an attribute to an action
When an attribute value has changed, it can be used to cause an action to be performed. A simple example of an attribute-to-action connection follows:
1. Place a Text part and a Push Button part within the default Window part in the Composition Editor.
2. Double click on the Push Button part to get the properties view. Set the enabled attribute to false. This means its default visual appearance is disabled.
3. Connect the object attribute of the Text part to the enable action of Push Button part.
The push button will become enabled as soon as a user types text into the Text part.
Connecting an event to an attribute
An event can be used to set an attribute value. In this case, a parameter must be used with the connection to supply the attribute value. A simple example of an event-to-attribute connection follows:
1. Place a Label part within the default Window part in the Composition Editor and change its object attribute in the property view to the string This is a window title.
2. Connect the openedWidget event of the default window part to the title attribute of the default window part.
Note:
Yes, connecting an event to an attribute for the same part does make sense in the right situation.
3. Now, to provide the parameter for the event-to-attribute connection you just created, connect the object attribute of the Label part to the value attribute from the connection pop-up menu.
When the window is opened its title text will be set to
This is a window title. This example is rather contrived, but it conveys the idea. For more information, see
Connection parameters.
Last modified date: 06/27/2019