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:
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)"