Menu and menu item properties, events and methods
Each menu (choose form.root in the Inspector’s drop-down object selector list) and menu item (form.root.itemname) has its own set of properties, events and methods, only a few of which were applied in the samples above. The following tables describe the primary elements you’ll use to define your menus.
Note
Where an element is available to only one of the menu classes, the class is noted in the tables below. Otherwise, the element is available to both menubar and popup classes.
Property |
Description |
alignment (popup only) |
Lets you align items on your popup menus and submenus. Options are left-aligned, centered, and right-aligned. Default is left-aligned. |
Identifies the object as an instance of the Menu, MenuBar or Popup class. | |
Identifies the object as an instance of a custom class. When no custom class exists, defaults to baseClassName | |
editCopyMenu, editCutMenu, editPasteMenu, editUndoMenu (menubar only) |
These four built-in objects are available for assignment to items on a preset Edit menu on a pulldown menu (menubar class). To access properties for these objects, click the object’s Tool button. |
left (popup only) |
Sets the position of the left border of the popup. Default is 0.00. |
String used to reference the root menu object. Except for Edit and Window menu names (which use the defaults EDIT and WINDOW), default for custom menus is ROOT. A reference to a default item would thus be this.root..menuNN, where NN is a system-assigned item number. | |
top (popup only) |
Sets the position of the top border of the popup. Default is 0.00. |
trackRight (popup only) |
Logical value (default true). Determines whether popup menu items can be selected with a right mouse click. If set to false, the popup menu is still opened with a right-click, but items must be selected with a left-click. |
windowMenu (menubar only) |
This built-in object is available for assignment to items on a preset Window menu on a pulldown menu (menubar class). To access properties for the WindowMenu object, click the object’s Tool button. |
Event |
Description |
Codeblock or reference to code that executes when the menu is initialized (when its parent form is opened). |
Method |
Description |
open( ) (popup only) |
Opens the popup menu. |
Removes the menu object definition from memory. |
Property |
Description |
Logical value (default false). Adds or removes a checkmark next to the item text. | |
Graphic file (any supported format) or resource reference. When the menu is run, the graphic you specify appears next to an item to indicate that it is currently selected. Alternative to the Checked property. Works with UncheckedBitmap to offer visual cues to the current "on/off" state of an item. | |
COPY, CUT, PASTE, or UNDO (dBL variable properties; available only to menubar class if preset Edit menu is in place)
|
If using a preset Edit menu, these references offer a Tool button to let you view or modify properties for the selected item. |
Logical value (default true) that dims or activates this item. | |
Specifies the Windows Help file that provides additional information about this item. If you choose to use a Help file, you must also specify a Help topic reference in the HelpId property. | |
Specifies a Help topic that you want to appear when the user presses F1 while selecting this item. If you specify a Windows Help file in the HelpFile property, HelpId is a topic reference within that Help file. You can either specify a context ID number (prefaced by #) or a Help keyword. | |
name |
String used to reference the item object. Except for Edit and Window menu names, default is MENUnn, wherenn is a system-assigned number. |
Designates a menu item as a separator bar. A separator bar appears as a horizontal line with no text; a user can’t choose or give focus to a separator bar. Use separator bars to begin a group of related menu items. You can also define a separator in the Menu or Popup Menu designers by choosing Menu|Insert Separator from the main dBASE Plus menu. | |
Specifies a keystroke or keystroke combination the user can press to choose the menu item. Shortcuts, also known as accelerators, provide quick keyboard access to a menu item. For example, you can set the ShortCut for an "Exit without saving" menu item to Ctrl+Q. To define a shortcut key for a menu item, enter it in the Shortcut property. For example, to specify the key combination Ctrl+X to exit a menu, enter CTRL-X. Thereafter, when the user presses Ctrl+X, the OnClick event occurs automatically. This key combination also appears in the menu title. | |
Type text here to display a message in the status bar (if a status bar object is included) of your non-MDI form, or, if you are attaching the menu to an MDI form, in the status bar of your application frame. | |
Item name, as it appears on the menu. You can also define item names directly in the Menu designer. To specify a letter as the mnemonic key that will be used to access the item, precede the letter in the text string with an ampersand (&). For example, Help menus are usually defined as &Help. | |
Graphic file (any supported format) or resource reference. When the menu is run, the graphic you specify appears next to the item to indicate that it is not currently selected. Works with CheckedBitmap to offer visual cues to the current "on/off" state of an item.
| |
Event |
Description |
"Action code" that executes when the item is clicked. If the item is an entry point to a pulldown or submenu, then no code is required for this event. Nor is code required for the items in the preset Edit or Window menus (described earlier in this chapter). | |
Optional code that executes when the user presses F1. Use this to provide user information as an alternative to using the HelpFile and HelpId properties to define an online Help topic.
| |
Method |
Description |
Removes the object definition from memory. |