HowToUseMenus topic
HowToUseMenus - hints for creating Menus for your Forms.Declaration
HowToUseMenusDescription
TMainMenu is the Main Menu that appears at the top of most forms;
form designers can customize by choosing various menu items.
TPopupMenu is a menu window that pops up with pertinent, usually
context-sensitive, details and choices when the right mouse button is clicked
near a control.
Main Menu is a non-visible component: that is, if the icon is selected from the Component Palette and placed on the Form, it will not appear at Run-time. Instead, a Menu bar with a structure defined by the Menu Editor will appear. Pop-up menus, placed on the form by selecting the icon from the Component Palette, do not appear at all unless the right mouse button is clicked on a control that owns such a menu.
To see the Menu Editor, right-click on the Main Menu or Pop-up Menu icon on your Form. A pop-up box appears, that invites you to enter items into the Menu bar.
An Edit box is displayed, containing a Button labeled New Item1. If you right-click on that box, a pop-up menu is displayed that allows you to add a new item before or after (along the same level) or create a sub-menu with the opportunity to add further items below (or above) the new item in a downward column.
Any or all of the MenuItems that you add can be configured using the Object Inspector.
At the least you should give each item a Caption which will appear
on the Menu Bar (you may also wish to give it a more meaningful
Name). The caption should indicate the activity to be selected,
such as "File Open" or "Close", "Run" or "Quit"
If you want a particular letter in the Caption to be associated with a
shortcut key, that letter should be preceded by an ampersand. The Menu item
at run-time will appear with the shortcut letter underlined, and hitting that
letter key will have the same effect as selecting the menu item.
Alternatively you can choose a shortcut key sequence (such as Ctrl-C for Copy
or Ctrl-V for Paste - the standard Keyboard shortcuts) with the
ShortCut property of the MenuItem.
It is often helpful to use the Menu controls in conjunction with an ActionList which contains a series of
standard or customized Actions. Menu
Items can be linked in the Object Inspector to Actions on the list, and the
same actions can be linked to Buttons, ToolBar Buttons, SpeedButtons etc. It is obviously
economic of effort to re-use the same code to respond to the various events,
rather than writing separate OnClick event handlers for each
individual control.
By default a number of standard actions are pre-loaded from StdActns or, if DataAware controls are being used, from DBActns, and these can be chosen using the ActionList editor which appears when you right-click on the ActionList icon on the Form Designer.
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
