Handling Events Through Wired Objects

Often, one object affects another through the result of an event. In the visual builder, you define this behavior by using the wire tool to wire two objects. You then use the Wire Manager to specify the event and how it's handled.


Note on Handling Events in Imported Classes

Before handling events in classes you've imported, see Imported Class Limitations.


Wiring Objects

Wire one object to another in one of two ways:

The result is a line representing the wire between the objects as shown below. A red wire indicates that the relationship between the objects hasn't been defined. Blue indicates a fully defined relationship.


Deleting the Wire Between Objects

Select the wire and choose Delete Wire from the Edit menu or from the right-mouse-button menu.


Specifying and Handling the Event

The sender object's event triggers behavior (calls a method) in the receiver object. The event passes an argument to the receiver. This argument can be Event.arg (type and content defined by the event) or an argument that consists of an object and a method.

  1. Display the Wire Manager in one of two ways:

  2. In the Sender box, specify the event (trigger) by selecting an event from the pull-down menu accessed from the down arrow to the left of the trigger field.

  3. If you want to provide your own argument for the receiver object, specify an object and method in the Argument box. Otherwise, use the default Event.arg object.

  4. In the Receiver box, specify the method that handles the event (input) by selecting a method from the pull-down menu.

    Notes:

  5. Click the Apply Changes button.

Note: Make certain you save the interface you've created in visual builder before you use the preview mode.

The Wire Manager page shows an example of wiring objects to handle an event.

Guide to the Cosmo Code Development Environment
12-96*528