Part 5. Making Simple Connections

A connection in the Visual Builder is used to associate an event with an action. For example, you can connect the buttonClick event for a push button to a built-in action such as closing the window, or to a member function you define for the visual part. In this section, you will create a simple connection to close the program when the user clicks Exit.

Here are the steps. Start in the Composition Editor's view of the MyGui part.

  1. Position the pointer over the Exit push button and click mouse button 2.
  2. From the pop-up menu, select Connect.
  3. From the cascading menu, select buttonClickEvent.
  4. A dashed line appears, with one end attached to the Exit push button, and a star at the other end:

    This line indicates that you are making a connection associated with the user clicking the Exit button. The kind of connection you can create depends on where you drop the star end of the line. Move the star up to the title bar of the frame window and press mouse button 1.

  5. A menu appears with the choices available when the buttonClickEvent action for a button is associated with the FrameWindow object. Select close so that when the button is clicked, the program closes.
  6. A green arrow appears, pointing from the Exit button to the titlebar. This means the connection has been made.
  7. Save and generate the part by pressing Ctrl+G or clicking the Generate Part Source icon . Switch back to the VisualAge C++ IDE and rebuild the project.
  8. Try running the project by clicking Run from the Run Specifications view of the project's Debug page. The window for your user interface should open, and when you click Exit, it should close. The other buttons still do not have any effect because you have not yet associated any actions with them.

You can proceed to either of the following sections: