The information in this article applies to:
- Microsoft FoxPro for Windows, versions 2.5x, 2.6x
- Microsoft FoxPro for MS-DOS, versions 2.5x, 2.6x
- Microsoft FoxPro for Macintosh, versions 2.5x, 2.6a
SUMMARY
In the Screen Builder, hot keys (also known as access keys) can be assigned
to push buttons. However, the Screen Builder does not provide a built-in
process for assigning hot keys to other screen GET objects, such as fields,
popups, list boxes, and so on.
The information below describes how to create hot keys for GET objects
other than push buttons by using the ON KEY LABEL statement, the _CUROBJ
system variable, and the OBJNUM() function.
NOTE: In Visual FoxPro for Windows, use the ActiveControl form property
instead of _CUROBJ and OBJNUM().
MORE INFORMATION
Overview
- Use the Line Drawing tool to simulate the underline of a character (the
underline font style is not supported in the Screen Builder). Select the
Line Drawing tool from the toolbox. Place a short line under the letter
in the field description that will be used in the hot key.
- In the SETUP snippet of the screen, place an ON KEY LABEL <ALT+key>
_curobj = OBJNUM(object) command. This commmand instructs FoxPro to jump
to the object when the hot key is pressed.
- Place a POP KEY command in the CLEANUP code of screen to clear the ON
KEY LABEL commands.
NOTES
If you are using memory variables in conjunction with SCATTER and GATHER
commands in the GET fields, remember to include the "m." (without the
quotation marks) alias with the field names.
The POP KEY command clears all ON KEY LABEL settings. If you are using F1
for help, add another ON KEY LABEL command to reassign the F1 key.
Similarly, restore any other needed ON KEY LABEL statements needed.
(Alternatively, investigate using the PUSH KEY command in the SETUP snippet
to store the original ON KEY LABEL assignments).
Example Using <Foxpro_Directory>\TUTORIAL\CUSTOMER.DBF
- Assuming FoxPro is installed in a directory named FOXPROW on drive
C, type the following commands in the Command window:
USE C:\FOXPROW\TUTORIAL\CUSTOMER
CREATE SCREEN test
- From the Screen menu, choose Quick Screen.
- In the Quick Screen dialog box, choose Fields.
- Move the CNO and COMPANY fields to the Selected Fields list box.
Choose OK twice to return to the Screen Design window.
- Select the Line Drawing tool from the toolbox. Place a line under
the letter "C" of the text object "Cno," which is located to the
left of the GET field for CNO. (In FoxPro for MS-DOS, choose Box
from the Screen menu. Size the box so that it appears as a line.)
- Select the Line Drawing tool again. Place a line under the letter
"o" of the text object "Company," which is located to the left of
the GET field for COMPANY. (In FoxPro for MS-DOS, choose Box from
the Screen menu. Size the box so that it appears as a line.)
- From the Screen menu, choose Layout.
- Under Options, choose Code. (In FoxPro for MS-DOS, do not select
anything--go directly to the next step.)
- Under Screen Code and Clauses, choose Screen Setup Code, and then
choose Cleanup and Procedures. Choose OK twice. (In FoxPro for MS-
DOS, under Screen Code, choose Setup. Then choose Cleanup and
Procedures. Choose OK once.)
- In the Setup snippet window, type the following:
ON KEY LABEL ALT+C _curobj = OBJNUM(CUSTOMER.CNO)
ON KEY LABEL ALT+O _curobj = OBJNUM(CUSTOMER.COMPANY)
- Close the Setup snippet window, saving changes.
- In the Cleanup snippet window, type the following:
POP KEY && Clear all ON KEY LABEL statements
ON KEY LABEL F1 HELP && Restore F1 to Help
- Close the Setup snippet window, saving changes.
- From the Program menu, choose Generate.
- When prompted to save changes to the screen, choose Yes.
- When prompted to save environment information, choose Yes.
- In the Generate Screen dialog box, choose Generate.
- Close the Screen Design window.
- In the Command window, type "DO test.spr" (without the quotation
marks).
Press ALT+O. Note that this selects the COMPANY GET field. Now press
ALT+C. This selects the CNO GET field.
For additional information on creating hot keys in Visual FoxPro, please
see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID:Q128752
TITLE :How to Use Hot Keys in Visual FoxPro
|