[futurebasic] Testing for F keys

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 1999 : Group Archive : Group : All Groups

From: scram@... (Stu Cram)
Date: Thu, 10 Jun 1999 06:48:47 -0700
- You can intercept the key codes before they are processed in PG programs
and check which one it is. The best place that I found to do this is within
the CANCEL filter that comes with the PG package. That routine checks for
cammand-period and I ajust add more speciall key combinations tthat check
for Function keys as well as some custom Command-Key combinations used as
shortcuts with buttons.
The main code now looks like like this:

LONG IF gLongAction& = _oEvents
LONG IF gWhat = _keyDwnEvt
' Use this next line to discover keyboard & ASCII Codes
' PRINT : PRINT  RIGHT$( HEX$({@gMessage&+2}), 4)
' This value has the key code in 1st byte
'    and the ASCII # in the 2nd byte
' This allows distintion between top row #s
'    and keypad #s, function keys, etc.
' I use it here mainly for common command buttons
'    in several windows
'  ie  NEXT, PREV, DONE, CANCEL, PROCEED, ERASE

SELECT {@gMessage& + 2} >> 8    ' get just the 1st byte

CASE &7B                        'Left arrow = Prev.
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Prev")

CASE &7C                    'Right arrow = Next
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Next")

CASE &02                   'D = Done
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Done")

CASE &2F                   'Period = Cancel
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Cancel")

CASE &23                   'P = Proceed (Many report windows, )
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Proceed")

CASE &01                   'S = Save (Enter Scores window)
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Save")

CASE &2D                   'N = New Gymnast(Setup windows)
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("New Gymnast")

CASE &03                   'F = Find Gymnast(Setup Gymnasts window)
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Find")

CASE &0E                   'E = Erase (all setup windows)
IF gModifiers AND _cmdKey% THEN FN checkKeyForButton("Erase")

' Here are the key codes for most special keys....
'     (add your own actions) as needed
'case &35    ' Esc key
'case &7A    ' F1 key
'case &78    ' F2 key
'case &63    ' F3 key
'case &76    ' F4 key
'case &60    ' F5 key
'case &61    ' F6 key
'case &62    ' F7 key
'case &64    ' F8 key
'case &65    ' F9 key
'case &6D    ' F10 key
'case &67    ' F11 key
'case &6F    ' F12 key
'case &69    ' F13 key
'case &68    ' F14 key
'case &71    ' F15 key

' case &74    ' Page Up key
' case &79    ' Page Down key
' case &73    ' Home key
' case &77    ' End key
' case &72    ' Help key
' case &75    ' fwd del key
' case &33    ' delete key
End SELECT

- Email me if you'd like all the code #s, etc.

Hope this helps.
- Stu Cram, FW Johnson Collegiate, Regina, Sask. Canada