Rich asked:
> Does anybody have a good routine for detecting function keys?
Rich,
Maybe this will be helpful. It compiles without error in both FB and
FBtoC. But I recommend you consider Carbon Events for new development.
Ken
/*
Function Key Demo — FB Old School
Compiles in FB and FBtoC
Carbon Events would be a better choice
to new applications, but this works
Ken Shmidheiser
March 18, 2008
PLEASE READ NOTE BELOW...
*/
_F1 = 122
_F2 = 120
_F3 = 99
_F4 = 118
_F5 = 96
_F6 = 97
_F7 = 98
_F8 = 100
/*
Note: The following function keys F9 through F15
are preassigned by System for certain functions.
I recommend not using this code with them.
_F9 = 9 // Activate Exposé
_F10 = 10 // Dim background
_F11 = 11 // Show Desktop
_F12 = 12 = 111 // Eject CD
_F13 = 13 = 104 // Print screen
_F14 = 14 // Scroll lock
_F15 = 15 // Pause
*/
local fn DoFKey( whichKey as Long )
'~'1
cls
select case whichKey
case _F1 : print "F1"
case _F2 : print "F2"
case _F3 : print "F3"
case _F4 : print "F4"
case _F5 : print "F5"
case _F6 : print "F6"
case _F7 : print "F7"
case _F8 : print "F8"
case else : exit fn
end select
end fn
local fn DoEvent
'~'1
dim ev as ^EventRecord
dim as Long keyCode
ev = Event
select case ( ev.what )
case _keyDwnEvt
keycode = ( ev.message >> 8 ) and 255
select case ( keycode )
case _F1 : fn DoFKey( keycode )
case _F2 : fn DoFKey( keycode )
case _F3 : fn DoFKey( keycode )
case _F4 : fn DoFKey( keycode )
case _f5 : fn DoFKey( keycode )
case _F6 : fn DoFKey( keycode )
case _F7 : fn DoFKey( keycode )
case _F8 : fn DoFKey( keycode )
case else : fn DoFKey( keycode )
end select
ev.what = _nullEvt
end select
end fn
on Event fn DoEvent
print "Press an FKey key."
do
HandleEvents
until gFBQuit