Article ID: 128752 - View products that this article applies to.
This article was previously published under Q128752
This article has been archived. It is offered "as is" and will no longer be updated.
Like FoxPro 2.x, Visual FoxPro provides support for access keys in objects. In addition to the standard types of access keys for objects, Visual FoxPro also now supports access keys on Label controls.
Access keys in Visual FoxPro work the same as they did in earlier releases of FoxPro. An access key combination is defined by including the control characters 'back slash-left angle bracket' (\<) within the text caption of the selected object.
You may be familiar with the use of access keys for an object such as a FoxPro 2.x push button. Visual FoxPro has extended this ability to include the Label control as well. In FoxPro 2.x, this functionality was difficult to achieve and required additional work on the part of the programmer.
In Visual FoxPro, access keys are added to label controls in the same manner as you would add one to any other object, such as a push button. It is important to keep the following key points in mind when using this functionality:
Step-by-Step ExampleIn the ORDENTRY screen of the TASTRADE project, located in the SAMPLES\MAINSAMP subdirectory of Visual FoxPro, the customer field has an access key value of C. The tab index order for the Label control is 1. Tab index 2 is the cboCustomer_Id field, so when ALT+C is pressed, focus moves to the cboCustomer_Id field. The following procedure shows how to examine this screen:
The following Visual FoxPro objects support the use of access keys:
CheckBoxFor objects like CommandGroups and PageFrame pages, you must select the appropriate object in the group. For example, in a PageFrame, to add an access key to a caption on a page, you must select the Page 1 object from the PageFrame. Note that Header objects in a grid don't support access keys.
If a user presses an access key combination for an object on a currently inactive form that is part of a FormSet, the inactive form will be activated. Pressing hot keys that are independent and separate from any FormSet will NOT activate the independent form.
Access keys on menus have not changed in Visual FoxPro. Although you can define an access key in a menu using by using the control character (\<) sequence, access keys must still be assigned to menu pads and bars by using the shortcut option. For the purposes of this document, shortcut key and access key are used interchangeably. As before, when a menu pad has an access key defined, you will not see any indicator that an access key has been assigned unless you specifically add the access or shortcut key sequence to the pad name.
Bars under a pad do not have to have the access key sequence assigned to the pad name. When a shortcut has been defined for a bar as it has been for the bar named 'A menu bar' below, Visual FoxPro will list the access key combination next to the pad name.
The order of precedence of menus and access keys has also not changed in Visual FoxPro. When two or more pads share the same access key combination, such as two pads both with a shortcut of ALT+Q, focus moves to the first pad by default.
When a bar in a submenu has the same shortcut key as a menu pad, focus still moves to the menu pad by default.
If you do define a shortcut key for a menu bar, you don't have to have any shortcut key text. Removing the key text will result in a cleaner menu look. You can then clue the user to the access key by putting the control key sequence (\<) in front of the letter which defines the access or shortcut key.
NOTE: You can also define a number hot key in a menu.
Contact us for more help