# Keeping the Cursor from Advancing on Push Button Object

ID: Q115110

The information in this article applies to:

- Microsoft FoxPro for MS-DOS, versions 2.0, 2.5, 2.5a, 2.5b, 2.6
- Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, 2.6

## SUMMARY

When the ENTER key is pressed, it sometimes is desirable to have the cursor stay on the same push button prompt in a set of multiple prompts in a push button object. However, doing this is not as simple as with other GET fields in a screen because FoxPro treats each prompt in a set of push buttons as a separate object, even though the push button set is defined as a single screen object.

This article describes two methods of keeping the cursor from moving to the next field.

## MORE INFORMATION

### Method 1

1. Open or create a new screen.

2. In FoxPro for Windows, use the Push Button tool to add a push button to

       the screen. In FoxPro for MS-DOS, choose Push Button from the Screen
       menu.

3. In the Push Button Prompts dialog box, enter the set of prompts. In

       FoxPro for Windows, choose the Variable button. In FoxPro for MS-DOS,
       choose the Choose button under Variable. In the resulting dialog box,
       type a variable name, for example "m.choice" (without the quotation
       marks). Choose OK.

4. In the Push Button dialog box, choose the Valid button in FoxPro for

       Windows. In FoxPro for MS-DOS, choose the Valid check box under Options.

5. In the resulting dialog box, select Procedure, and then enter the CASE

       statements that you want to have executed. Add the following lines of
       code immediately after the final ENDCASE statement:

          _CUROBJ = OBJNUM(m.choice)+(m.choice-1)
          SHOW GETS

6. Generate and run the screen.

### Method 2

1. Follow steps 1-5 above; however, instead of entering the code shown in

       step 5, add the following lines of code immediately after the final
       ENDCASE statement:

          SHOW GETS
          RETURN 0

2. Generate and run the screen.

When the appropriate push button is chosen, pressing ENTER will execute the command, but will not cause the cursor to move to the next button or field.

Additional reference words: FoxDos FoxWin 2.50b 2.60 stay moving stop prevent KBCategory: kbprg KBSubcategory: FxprgGeneral

Last Reviewed: June 27, 1995 © 1999 Microsoft Corporation. All rights reserved. Terms of Use.