Responding to Special Keys

The data entry functions (inpm_x(), and askf_x()) always return when the user moves away from the field. The return value usually indicates how this was done by returning values such as LEFT, RIGHT and so on, defined in the file dp4uiapi.h. (These particular values would only be returned by the inpm_x() family, because the askf_x() functions don't allow the user to move away from the current field like this.)

By default only the keys used by DP4 for moving around fields cause inpm_x() to lose focus and return. Frequently applications work by allowing users to enter a value and then press a function or other special key. It is common in retail systems for keyboards to have one hundred or more such special keys. These are normally mapped (using the keyboard configuration option in DFSETUP) to generate function keys such as F170 F97 and son on.

There are two ways to enable your input fields to respond to special keys like this:

The first technique is more appropriate if you want all input fields to respond to function keys, the second if you only want to respond to function keys at specific points in the application. Note that your application will be notified of all function keys when this flag is set (the return value from inpm_x() will be a positive number corresponding to the function key, for example pressing function key 97 will cause inpm_x() or askf_x() to return 97, and set abort_code to the same value). If the user presses a function key that has no meaning you can either display an error message or beep, or simply call the interrupted input function again.

If you want to take special action when one of the following four special keys is pressed : <Page Up>,<Page Down>, <Insert>, <Delete>, then you must set the CURS_KEYS flag instead of or as well as the FUNC_KEYS flag. The CURS_KEYS flag is used by functions like pick_record() to allow the user to move to another "page" of a pop-up window or list box.