How Do I...

See what a connection is

Connect parts to add function to my application No tip for this topic No example for this topic Draw a connection between parts

Once you add user interface parts to your application, to add function to your application you need to connect the parts.

Each part has attributes, events, and actions. When you connect parts, you connect one part's attribute, event, or action to another part's attribute, event, or action.

For example, suppose the user interface for your application has a push button Show, a text field that displays "Initial text" when you open the application, and some Smalltalk code that returns "Later text".

If you press Test to open your application's window, and then press its Show button, nothing happens.

To make your application run the Smalltalk code (or script) and display "Later text" in the text field when you press Show, you must add the connections shown below:
Window with event-to-action connection

The green line is an event-to-action connection. It connects the push button's clicked event to the text field's object action.

The blue line is an attribute-to-script connection. It connects the event-to-action connection's value attribute to the Smalltalk code.

This might seem complex now. But it only takes a few seconds to make the connections. And, once you've tried different types of connections, it becomes straightforward.

Attributes

Attributes are a part's data that other parts can access. The data can represent any logical property of a part, such as the label of a push button.

A part can set or return attributes upon request.

Events

Events are signals that something has happened to a part. These signals are sent to other parts.

An event might be a push button being clicked, the closing of a window, the starting of an application, the changing of an attribute value, or any number of other things done to a part.

As to connections, you use events to trigger actions or running of scripts. For example, you might connect the clicked event of a push button to the openWidget action of a new window. Then, when a user clicks on the push button, another window opens.

Actions

Actions are services or operations that a part can perform. Actions can be triggered by connections from other parts. For example, the execute action of an application can be triggered by the closing of a window or clicking of a push button.

Scripts

Scripts are Smalltalk statements that implement action for a part. Scripts are also known as methods.

An example of a script is as follows:

wordsToShow
  "Return the string: Later text."
  | words |
  words := 'Later text'.
  ^words
 

This script named wordsToShow, when run, returns the words Later text.


[ Top of Page | Previous Page | Next Page | Table of Contents ]