Evaluates a key label (such as F1) for a key in the predefined set of keyboard keys and returns the corresponding = key code (such as 301) as an INTEGER value. See OpenEdge Development: Programming Interfaces for a list of key codes and key labels.
This procedure displays a menu and highlights different selections on the menu depending on which key you press. On the first iteration of the REPEAT block, the COLOR statement tells the AVM to color msg[ix] with the same color used to display messages. Because the initial value of ix is 1, msg[ix] is the first menu selection. Therefore, the first menu selection is colored MESSAGES.
r-keycod.p
DEFINE VARIABLE msg AS CHARACTER NO-UNDO EXTENT 3. DEFINE VARIABLE ix AS INTEGER NO-UNDO INITIAL 1. DEFINE VARIABLE newi AS INTEGER NO-UNDO INITIAL 1. DISPLAY " Please choose " SKIP(1) " 1 Run order entry " @ msg[1] ATTR-SPACE SKIP " 2 Run receivables " @ msg[2] ATTR-SPACE SKIP " 3 Exit " @ msg[3] ATTR-SPACE SKIP WITH CENTERED FRAME menu NO-LABELS. REPEAT: COLOR DISPLAY MESSAGES msg[ix] WITH FRAME menu. READKEY. IF LASTKEY = KEYCODE("CURSOR-DOWN") AND ix < 3 THEN newi = ix + 1. ELSE IF LASTKEY = KEYCODE("CURSOR-UP") AND ix > 1 THEN newi = ix - 1. ELSE IF LASTKEY = KEYCODE("GO") OR LASTKEY = KEYCODE("RETURN") THEN LEAVE. IF ix <> newi THEN COLOR DISPLAY NORMAL msg[ix] WITH FRAME menu. ix = newi. END. |
When you press the cursor-down key, the following occurs: