Microsoft KB Archive/108037

{| = PRB: ENTER Does Not Activate the Default Push Button =
 * width="100%"|

ID: Q108037

2.5x 2.60 WINDOWS kbprg kbprb kbdocerr

The information in this article applies to:


 * Microsoft FoxPro for Windows, versions 2.5x, 2.6

SYMPTOMS
In a screen that contains push buttons along with various other screen objects, the ENTER key does not always activate the default push button. Depending on the type of screen object (other than a push button) the cursor is in, pressing the ENTER key may advance the cursor to the next object, do nothing, or activate the default push button.

The CTRL+ENTER key combination, however, always activates the default button.

NOTE: The key combination above does not work if the screen contains only push buttons and no other objects.

RESOLUTION
Use the ON KEY LABEL command to send a CTRL+ENTER keystroke to the screen when the ENTER key is pressed.

Example Using the Screen Builder with Input Fields
1. Use the Screen Builder to create a new screen.

2. Select the Field tool from the toolbox and place an input field (GET) in the screen. Place any field or variable in the Input text box. Press OK to return to the Screen Design window.

3. Repeat step 2, so that two fields are placed in the screen.

4. Select the Push Button tool from the toolbox and place a push button in the screen.

5. Under Push Button Prompts, type "First" (without the quotation marks) in the first column.

6. Still under Push Button Prompts, type "\!Default" (without the   quotation marks) in the second prompt area. (The backslash and   exclamation mark characters (\!) at the beginning of the push button    prompt designate it as the default push button.)

7. In the Variable text box, type "m.test" (without the quotation marks). Choose OK to return to the Screen Design window.

8. From the Screen menu, choose Layout. Under Options, choose the Code button.

9. In the Screen Code dialog box, choose the Screen Setup Code button and the Cleanup and Procedures button. Choose OK twice. 10. In the Setup snippet window, type the following: ON KEY LABEL ENTER KEYBOARD '{CTRL+ENTER}' 11. In the Cleanup snippet window, type the following: ON KEY LABEL ENTER 12. Save the screen as TEST.SCX (assuming you do not already have a file  with the same name). 13. Generate TEST.SPR, then close the Screen Design window. 14. Run TEST.SPR. Note that when you press the ENTER key, the default push

button is activated. NOTE: If you remove the code from the Setup and Cleanup snippet windows, regenerate the screen, and then run it, you will observe that pressing the ENTER key advances the cursor through the first two fields instead of pushing the default push button.

MORE INFORMATION
According to the online Help information for the SET KEYCOMP command and page L3-943 in the "Language Reference" manual, pressing the ENTER key always performs the default button's action when KEYCOMP is set to WINDOWS. However, this statement is not correct for all types of screen objects. When the cursor is in certain screen objects and the ENTER key is pressed, the cursor may advance to the next object, or it may remain in the current object.

When KEYCOMP is set to DOS, the key combination CTRL+ENTER always activates the default push button. This key combination also works when KEYCOMP is set to WINDOWS.

NOTE: The default push button is designated by the backslash and exclamation mark characters (\!) in the Screen Builder.

Additional reference words: FoxWin 2.50 2.50a 2.50b 2.60 pushbutton KBCategory: kbprg kbprb kbdocerr KBSubcategory: FxtoolSbuilder

Keywords         : FxtoolSbuilder Version          : 2.5x 2.60 Platform         : WINDOWS
 * }