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.
- Position the pointer over the Exit push button and click mouse button
2.
- From the pop-up menu, select Connect.
- From the cascading menu, select buttonClickEvent.
- 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.
- 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.
- A green arrow appears, pointing from the Exit button to the titlebar.
This means the connection has been made.
- 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.
- 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: