All Manuals > LispWorks IDE User Guide > 20 The Interface Builder

NextPrevUpTopContentsIndex

20.4 Creating a menu system

The menus view of the Interface Builder can be used to define a menu system for the current interface. Click the Menus tab to switch to the menus view from any other view in the Interface Builder. The Interface Builder appears as shown in Displaying the menu structure of an interface.

Figure 20.5 Displaying the menu structure of an interface

The menus view has two areas, together with six buttons which are used to create different menu elements. As with layouts, it is important to understand how CAPI menus are constructed. See the CAPI User Guide and Reference Manual for details.

20.4.1 Interface box

This box is identical to the Interface box in the layouts view. See Interface box for details.

20.4.2 Graph area

The graph area in the menus view is similar to the graph area in the layouts view. It displays, in graph form, the menu system that has been defined for the current interface. Menu items are displayed as the children of menus or menu components, which in turn are displayed as the children of other menus, or of the entire menu bar.

Like the layouts view, a new menu element is added as the child of the currently selected item in the graph, or the last selected element if nothing is currently selected.

20.4.3 Adding menu bars

A single menu bar is created in any new interface by default. This appears in the graph area as a child of the entire interface.

If you decide to delete the menu bar for any reason, use the Menu Bar button to create a new one.

20.4.4 Adding menus

To add a menu, click Menu on the button bar at the bottom of the Interface Builder. Each menu must be added as the child of the menu bar, or as the child of another menu or menu component. In the first case, the new menu is visible on the main menu bar of the interface. Otherwise, it appears as a submenu of the relevant menu.

Newly created menus cannot be selected in the interface skeleton until menu items or components are added to them.

By default, new menus are called MENU-1, MENU-2 and so on, and appear in the interface skeleton as Menu-1 , Menu -2 and so on, as relevant. See Performing operations on objects for details on how to change these default names.

20.4.5 Adding menu items

To add a menu item to the current interface, click Item on the button bar. Each menu item must be added as the child of either a menu or a menu component. If added as the child of a menu component, new items have a type appropriate to that component; see Adding menu components for details.

By default, new menu items are named ITEM-1, ITEM-2, and so on, and are displayed in the interface skeleton as Item-1 , Item-2 and so on, as relevant. See Performing operations on objects for details on how to change these default names.

20.4.6 Adding menu components

Menu components are an intermediate layer in the menu hierarchy between menus and menu items, and are used to organize groups of related menu items, so as to provide a better structure in a menu system.

There are three types of menu component which can be defined using CAPI classes:

20.4.6.1 Standard menu components

A standard menu component can be used to group related menu commands that would otherwise be placed as direct children of the menu bar they populate. This offers several advantages.

Click Component in the button bar to add a standard menu component to the current interface. Menu components must be added as the children of a menu. Menu components are not visible in the interface skeleton until at least one item or submenu has been added, using the Item or Menu buttons.

Menu items added to a standard menu component appear as standard menu items in that component.

20.4.6.2 Radio components

A radio component is a special type of menu component, in which one, and only one, menu item is active at any time. For any radio component, capi:item-selected always returns t for one item , and nil for all the others. The menu item that was selected last is the one that returns t.

Radio components are used to group together items, only one of which may be chosen at a time.

Click Radio Component in the button bar of the Interface Builder to add a radio component to the current interface. Radio components must be added as the children of a menu, and, like standard menu components, are not visible in the interface skeleton until items have been added. To add an item to a radio component, click Item . New items are automatically of the correct type for radio components. Note that you cannot add a submenu as an item in a radio component.

The way that a selected radio component is indicated on-screen depends on the operating system or window manager you are running; for example it may be a dot or tick to the left of the selected item. On some systems, a diamond button is placed to the left of every item, and this is depressed for the item which is currently selected.

Like standard menu components, separators divide radio components from other items or components in a given menu.

20.4.6.3 Check components

Like radio components, check components place constraints on the behavior of their child items when selected. For each item in a check component, capi:item-selected either returns t or nil, and repeatedly selecting a given item toggles the value that is returned. Thus, check components allow you to define groups of menu items which can be turned on and off independently.

An example of a check component in the LispWorks IDE are the commands in the Tools > Customize menu, available from any window in the environment.

Click Check Component in the button bar of the Interface Builder to add a check component to the current interface. Like other components, check components must be added as the children of a menu, and are not visible until items have been added. Use the Item button to add an item to a check component; it is automatically given the correct menu type. Note that you cannot add a submenu as an item in a radio component.

Like radio components, the way that check components are indicated on-screen depend on the window manager or operating system being used. A tick to the left of any items which are "switched on" is typical. Alternatively, a square button to the left of check component items (depressed for items which are on) may be used.

20.4.7 Removing menu objects

To remove a menu object from your interface definition, select it in the Graph area of the Menus view and choose Edit > Cut or press the toolbar button.


LispWorks IDE User Guide (Unix version) - 12 Feb 2015

NextPrevUpTopContentsIndex