Part 3. Adding User Interface Controls to a Visual Part

Your visual part so far displays only a frame window with the title FrameWindow. In this section you will:

When you are finished this section, your application will look similar to this:

Open the MyGui part in the Visual Composition Editor

Before you start adding parts or changing the title, you need to open the part in the Visual Composition Editor. Follow these steps:

  1. Select the Parts page of the Project section.
  2. On the Parts page, select MyGui in the Parts view. Make sure you select this part and not the MyMain part.
  3. Click Edit Part in the Part Launch view, to launch the part in the Visual Builder.

A Composition Editor view of the MyGui part opens in a separate Visual Builder window.

Change the Title of the Frame Window

To change the title that appears in the frame window to something more meaningful than the default name FrameWindow, follow these steps:

  1. In the Composition Editor, hold down the Alt key and click mouse button 1 on the title area of the titlebar. This area becomes an entry field. Enter a title, for example Review Tool User Administration.
  2. To finish the input, click a different area of the Composition Editor work area.

Add Parts

Parts are added to your workspace with the parts palette. The parts palette looks like this:

The Sticky check box at the bottom of the palette is used whenever you want to add several parts of the same type onto the canvas in succession. This saves you from having to repeatedly select a part type. To turn of sticky parts, deselect the Sticky check box.

Generally, you add parts to a canvas in three steps:

  1. Select the parts category from the left column of the parts palette.
  2. Select the type of part you want from the right column of the parts palette.
  3. Click anywhere on the canvas to place the selected part.

These steps will be listed again. If you accidentally add a part you did not want, you can remove it by selecting the part and pressing the Delete key.

Add a List Box

Now you will add a list box to the left side of your window to display the names of existing users.

  1. Click the Lists category , then click the IListBox* part type .
  2. Move the mouse pointer just inside the top left corner of the canvas inside the frame window. Click mouse button 1. A list box is added to the canvas.
  3. The Composition Editor gives each new object a default name of ObjectType plus a number. Because you will be writing code that uses this object, you should rename it from ListBox1 to UserList. Click mouse button 2 to raise a pop-up menu over the list box.
  4. There are two ways to change the part name:
  5. Click OK to close the Properties dialog or the Name Change Request dialog.

Add Buttons

Next, you will add five buttons:

  1. Click the Buttons category . Click the IPushButton* part type , then click the Sticky check box at the bottom left.
  2. Click four times in a vertical line down the center of the canvas to drop four buttons. These will be the buttons used to edit, delete, add, and save user entries.
  3. Click a fifth time just inside the bottom right corner of the canvas. This will be your Exit button.

Now change the displayed text for the five buttons to indicate their intended functions. First, turn off the Sticky checkbox. Then, hold down the Alt key, left click each button, and enter the text. Change the button text as follows, from top to bottom:

The last controls you need are two text input fields for the user's name and key, a spin button field for the user's authority level, and three static text fields describing those input fields.

Add Text Fields

Begin with the text fields. Click the Data Entry parts category , and click the IStaticText* part type . Turn on the Sticky check box if it is turned off. Add three static text objects to the right of each of the topmost three push buttons. Do not worry about exact placement yet.

Turn off the Sticky check box to stop adding static text objects.

Select each of the static text objects you just created, by holding down the Alt key and clicking mouse button 1. Change the text for the three static text objects as follows:

Add Entry Fields

Next, add a text entry field under User Name and User Key. Click the IEntryField* part type , turn on the Sticky check box, and click in the space underneath each of these text objects. Turn off the Sticky check box.

Rename the two entry fields to UserName and UserKey by clicking mouse button 2 over the object, selecting Change Name, and entering the new name in the dialog that appears (you can also do this by editing the Part name field in the Properties dialog.)

Add Spin Buttons

Add one last part, a text spin button for the authority level. Click the Buttons category , and the ITextSpinButton* type . Drop an ITextSpinButton object under the Authority Level text. Rename the spin button to AuthorityLevel.

You need to add a set of three text choices to the spin button, and change some settings on it to make the spin button display properly:

  1. Click mouse button 2 over the spin button and select Open Settings.
  2. In the Properties dialog, scroll down to the initialContents field. Select the entry field beside this field, and a button appears. Click this button.
  3. Enter the following text on separate lines in the Array of strings prompter dialog, then click OK:
    Reader
    Reviewer
    Author
  4. Click OK twice, to close the Properties dialog.

Try Your Program

The layout of your user interface is a bit messy, but it would still be nice to try out the interface. Press Ctrl+G or the Generate Part Source toolbar icon, to generate part source for the part. From the File menu select the name of your configuration file so that the IDE window is displayed (if you minimized the IDE, restore its window). Within the IDE, build the project, then press Ctrl+Shift+R to run the project (or, from the Debug page's Run specification view, click Run).

If you try clicking a button in the application, nothing happens, because you have not yet made connections between the buttons and actions. An example of an action related to a button would be the closing of the window when the Exit button is pressed. You will start making these connections in Part 5.

You can proceed to either of the following parts: