INF: How to Automatically Move Cursor to End of EDIT Field
PSS ID Number: Q113970
Article last modified on 11-15-1994
PSS database name: FOXPRO

2.50b      | 2.50 2.50a 2.50b 2.60 | 2.50 2.50a 2.50b 2.60
MACINTOSH  | MS-DOS                | WINDOWS

--------------------------------------------------------------------
The information in this article applies to:

 - Microsoft FoxPro for Macintosh, version 2.5b
 - Microsoft FoxPro for MS-DOS, versions 2.5, 2.5a, 2.5b, and 2.6
 - Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b, and 2.6
--------------------------------------------------------------------

SUMMARY
=======
In order to facilitate text editing, you may need to place the cursor at
the end of an edit region both upon entering a screen and upon moving to
another record in the database. For information about how to do this, see
below.

MORE INFORMATION
================
In order to describe the steps necessary to create a screen that
automatically moves the cursor to the bottom of an edit region, this
article makes the following assumptions:

 - The database used by the screen is called CUSTOMER.DBF.
 - The memo field is called NOTES.
 - The first GET field in the screen is for the field CNO.
 - The first field and the EDIT region are not disabled.
 - A series of buttons is employed to navigate the database.

Upon executing a screen program, the first object activated is usually the
first GET field. Therefore, the WHEN procedure of the first GET field will
be used to send the cursor to the EDIT field. However, since you might want
to enter data in the first GET field, a conditional test must be performed
to allow this to happen only the first time the field is entered. To set up
this condition, place the statement

   m.flag = .f.

in the Setup code for the screen in the Screen Builder. By testing this
variable in the WHEN clause of the CNO field (the first field) and then
changing its value, you can allow entry into CNO instead of always jumping
to the EDIT field. Placing the following code in the WHEN clause for the
CNO field will accomplish this:

   IF ! FLAG
     _CUROBJ=OBJNUM(customer.notes)  && moves cursor to EDIT field
     m.flag = .t.                    && allow access to CNO next time
   ENDIF

Now that you have arranged to have your cursor move to the EDIT region, you
are ready to perform the desired function; namely, moving the cursor to the
bottom. In preparation, the EDIT region must be set so that the entire
field is SELECTed ON ENTRY. Then, place the following code in the WHEN
clause for the EDIT field:

   KEYBOARD("{DNARROW}")

Because the entire field is selected, you only need to code one "down
arrow" character to move to the bottom of the field. The only step
remaining is to modify the VALID procedure for the navigation buttons. This
code usually consists of a DO CASE statement to process the different
buttons. Usually, the last statement in the VALID procedure will be SHOW
GETS (used to refresh the screen). Add a line immediately before the SHOW
GETS line as follows:

   _CUROBJ = OBJNUM(customer.notes)

This is the same statement you used in the WHEN procedure of the first
field to move the cursor to the EDIT field. When the screen is generated
and run, every time you move to another record using the buttons, the
cursor will be placed at the bottom of the EDIT field.

Additional reference words: FoxMac FoxDos FoxWin 2.50 2.50a 2.50b 2.60
KBCategory: kbui kbprg kbcode
KBSubcategory:

=============================================================================
Copyright Microsoft Corporation 1994.