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.
Wire one object to another in one of two ways:
-
Using the wire tool
,
press the left mouse button over the sending object, drag the cursor to
the receiving object, and release the button.
-
Using the selection tool
,
hold down the Alt key and press the left-mouse button over the sending
object. Drag the cursor to the receiving object, and release the button
and the Alt key.
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.
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.
-
Display the Wire Manager in one of two ways:
-
Select a wire and choose Show Wire Manager... from the menu bar or from
the right-mouse-button menu.
-
Double-click a wire.
-
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.
-
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.
-
In the Receiver box, specify the method that handles the event (input)
by selecting a method from the pull-down menu.
Notes:
-
The 1.0.2 JDK Style events are listed in upper case and that the 1.1
JDK Style events are lower case.
-
If you specify 2 wires, one as a 1.0.2 event and one as a 1.1 event,
the 1.0.2 event is ignored. If both wires are the same style, they are
both used.
-
While you can mix events, using only 1.1 style events provides better
performance.
-
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