15 Example: Using The Interface Builder

15.2 Specifying attribute values

As you have already seen, the interface builder assigns default names such asRow-Layout-1 to the elements you add to an interface; you usually want to replace these with your own names. In addition, there are probably titles that you want to add to the interface; you can see the default titles that have been created by looking at the interface skeleton. The next stage of the example shows you how to change these default names and titles.

Changing the name or title of an element is actually just a case of changing the value assigned to an attribute of that element, as described in Section 14.5.4 on page 201. You would normally assign values to a number of different attributes at once, rather than concentrating on the names and titles of elements. The example is structured in this way to give you an idea of the sort of working practices you might find it useful to adopt when generating interface code.

To recap, the layout hierarchy of the example interface is shown in Figure 15.2. To ensure that you can understand this layout easily in the future, it is important to assign meaningful names and titles to the elements it contains now.

Figure 15.2 Layout hierarchy of the example interface

1. Select theINTERFACE-1 object and press Return.

The Attributes dialog appears as shown in Figure 15.3.

Figure 15.3 Attributes dialog for the example interface

Notice that the NAME attribute of the interface has the valueINTERFACE-1, and the TITLE attribute has the value"Interface-1".

Note: If this is not the first interface you have created in the current session, the number is different.

2. Delete the value in the NAME text input pane, and typeib-example.

3. Delete the value in the TITLE text input pane, and type"Example Interface".

4. Click OK to dismiss the Attributes dialog and update the interface.

The name of the interface is now displayed asIB-EXAMPLE in the Layout hierarchy area, and the title of the interface skeleton changes toExample Interface.

Note: Case is not significant in the NAME attribute, because it is a Common Lisp symbol, but it is significant in the TITLE attribute, which is a string.

5. Select theColumn-Layout-1 element, display its Attributes dialog, and change the value of its NAME attribute tomain-layout.

Now change the names of the other objects in the interface.

6. Select the graph pane and change its NAME attribute tograph, and its INTERACTION attribute to:extended-selection. Click OK.

7. Select the list panel and change its NAME attribute tolist, and its INTERACTION attribute to:extended-selection. Do not click OK yet.

The value of the INTERACTION attribute allows you to select several items from the list panel and the graph pane, using the appropriate method for your platform.

8. Change the ITEMS attribute of the list panel to the following string:

'("One" "Two" "Three" "Four" "Five" "Six" "Seven" "Eight")

9. Click OK.

The row layout you created contains objects which are used solely to display information.

10. Select the row layout object and change its NAME attribute todisplay-layout.

11. Change the ADJUST attribute of the row layout to:center. Click OK.

Changing the ADJUST attribute centers the title pane and the display pane vertically in the row layout, which ensures they line up more pleasingly.

In the working example, thedisplay-layout object is going to show information about the current selection, so you need to change the names and titles of the objects it contains accordingly.

12. Select the title pane and change its NAME attribute toselection-title and its TEXT attribute to"Selection:". Click OK.

13. Select the display pane and change its NAME attribute toselection-text, and its TEXT attribute to"Displays current selection". Click OK.

This specifies a text string which is printed when the interface is initially created. This string disappears as soon as you perform any action in the interface.

The layout hierarchy is now as shown in Figure 15.4. The names that you have assigned to the different objects in the interface make the purpose of each element more obvious.

Figure 15.4 Layout hierarchy with names specified


Common LispWorks User Guide, Liquid Common Lisp Version 5.0 - 18 OCT 1996

Generated with Harlequin WebMaker