Ultra Light Client Guide and Reference


Menu general advice

Several classes implement menu support.

To build a menu bar visually, drop a Menubar part on the free-form surface and connect its self attribute to the menuBar attribute of a Shell part. Then drop Menu parts on the Menubar part. VisualAge adds the appropriate parts and a connection for each Menu part dropped.

To build a pop-up menu visually, drop a Menu part on the free-form surface and connect its self attribute to the popupMenu attribute of a UI part.

Then drop any of the following parts on each Menu part:

A menu can be made dynamic by linking it to an attribute of a FormModel or RowModel. For examples, see UlcMenu>>#model:, UlcMenu>>#attributeName:, and UlcMenu>>#attributeValue:. The menu's visibility is then dependent on the value of that attribute, making the menu dynamic.

Mnemonics

Menus and their items support mnemonics. The following code sets the mnemonic of a menu to F:

UlcMenu new
 label: 'File';
 setMnemonic: $F;
 yourself

Code example

Creating a menu bar requires the following steps:

  1. Create an instance of UlcMenuBar and add it to UlcShell.
  2. Add instances of UlcMenu to the menu bar.
  3. Add instances of UlcMenuItem to each menu.
  4. Optionally, separate the menu items with UlcSeparator.

    These steps are implemented as follows:

    |shell menuBar fileMenu|
    (shell := UlcShell new) setMenuBar: (menuBar := UlcMenuBar new). "(1)"
    (fileMenu := UlcMenu new)  "(part of step 2)"
     label: 'File';
     add: (UlcMenuItem new     "(3)"
       label: 'Quit';
       addActionCallbackFor: shell
       ulcApplication selector: #close clientData: nil;
       yourself).
     menuBar add: fileMenu     "(remainder of step 2)"
    


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]