xHarbour Reference Documentation > Function Reference |
Queries or changes all SetKey() code blocks.
HB_SetKeySave( [<aNewKeyBlock>] ) --> aOldKeyBlock
When NIL is explicitly passed for <aNewKeyBlock>, all active SetKey() code blocks are voided.
The function returns a two dimensional array holding the previous key/code block associations.
HB_SetKeySave() queries all active key/code block associations defined with the SetKey() function. Optionally, new SetKey() code blocks can be defined with <aNewKeyBlock> or they can be voided when NIL is passed to the function.
When the return value is passed to HB_SetKeySave(), all previously defined SetKey() code blocks become active again.
See also: | Inkey(), RestSetkey(), SaveSetkey(), SetKey() |
Category: | Environment functions , Keyboard functions , xHarbour extensions |
Source: | rtl\setkey.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example defines SetKey() code blocks which branch to // sub-routines while READ is executed. To suppress recursive // calls within sub-routines, all key/code block associations // are voided and restored with HB_SetKeySave(). #include "Inkey.ch" PROCEDURE Main LOCAL cString := "Testing HB_SetKeySave()" CLS SET KEY K_F2 TO F2_Key SET KEY K_F3 TO F3_Key @ 10,10 SAY "Press F1, F2 or F3" GET cString READ RETURN PROCEDURE Help( cProcName, nProcLine, cReadVar ) LOCAL cScreen := SaveScreen() LOCAL aSaved := HB_SetKeySave( NIL ) // no recursive calls CLS ? "Help routine" ? "Called from:", cProcName, nProcLine, cReadVar WAIT HB_SetKeySave( aSaved ) Restscreen(,,,, cScreen ) RETURN PROCEDURE F2_Key( cProcName, nProcLine, cReadVar ) LOCAL cScreen := SaveScreen() LOCAL aSaved := HB_SetKeySave( NIL ) // no recursive calls CLS ? "F2 key pressed" ? "Called from:", cProcName, nProcLine, cReadVar WAIT HB_SetKeySave( aSaved ) Restscreen(,,,, cScreen ) RETURN PROCEDURE F3_Key( cProcName, nProcLine, cReadVar ) LOCAL cScreen := SaveScreen() LOCAL aSaved := HB_SetKeySave( NIL ) // no recursive calls CLS ? "F3 key pressed" ? "Called from:", cProcName, nProcLine, cReadVar WAIT HB_SetKeySave( aSaved ) Restscreen(,,,, cScreen ) RETURN
http://www.xHarbour.com