Using the Return Key to Advance

Last updated:
June 12, 1997

Problem:

In Windows the <Tab> and <Shift - Tab> keys are used to advance or backtrack from one element to another. Many people are used to hit the <RETURN> key after entering data in an edit field and this way of entering data is cumbersome. They would like to continue to use the Return key after an edit field has been filled.

Solution:

You can find an example in the Tutorial vocab, MENU TEST, Procedures, Return Key Advance. The form is called FORM PROCEDURE.

With few lines of code you can use the <RETURN> key to advance in a Pragma form.

In the Got focus event of each edit field copy the Tab stop number of the edit field to a noun, called for instance, LAST FOCUS.

For example, in the edit field that has the Tab stop number 4 do a COPY the value 4 to the noun LOST FOCUS.

The form must contain an invisible button. This button must have the property Default button = TRUE (1). In the Pushbutton pushed event of the button you enter the following lines of code:

  1. IF the value LAST FOCUS "=" the value 1

    do

  2. SET ELEMENT PROPERTY element EDIT 2 property PROPERTY FOCUS to the value TRUE

  3. IF the value LOST FOCUS "=" the value 2

    do

  4. SET ELEMENT PROPERTY element EDIT 3 property PROPERTY FOCUS to the value TRUE

and so on.

EDIT 2 is the name of the Edit field that has the Tab stop of 2.

You should synchronize the Tab stop with you <RETURN> procedure not to confuse a user that hits the <TAB> and <SHIFT-TAB> keys instead of the <RETURN> key.

 

Warning:

The above procedure works only with single line edit fields, combo boxes and list boxes.

Multi line edit fields, grids use the Return key and you cannot use it for the procedure described above.

 

00-05-08
lip_tec3.gif
t_ret_pr.htm