FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about SET KEY
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about SET KEY
Posted: Sat Nov 24, 2007 01:07 AM
Hello,

If I use this code :
SET KEY VK_F5 TO TestPro


then the function TestPro() will be executed if the F5-key is pressed.

But now my question :

How can I read in another part of my appliction to which function the F5-key is linked ?

Thank you.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Question about SET KEY
Posted: Sat Nov 24, 2007 11:33 AM

Michel,

You can't unless you store the function name yourself, and later on you search for it:

public aKeys := {}

SET KEY VK_F5 TO TestPro

AAdd( aKeys, { VK_F5, "TestPro" } )

You could modify the #xcommand SET KEY ... so it does it automatically for you

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about SET KEY
Posted: Sat Nov 24, 2007 12:52 PM

Antonio,

Thanks a lot for your answer.

Until now, I never used #xcommand.

Please could you tell me how to solve my problem using #xcommand ?

Thanks a lot in advance.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Question about SET KEY
Posted: Sat Nov 24, 2007 01:06 PM
Michel,

Here you have it working:
#include "FiveWin.ch"

#command SET KEY <n> TO <proc> ;
      => SetKey( <n>, {|p, l, v| <proc>(p, l, v)} ) ;;
         AddKey( <n>, <(proc)> ) 

memvar aKeys

function Main()

   public aKeys := {}

   SET KEY VK_F5 TO Test

   MsgInfo( KeyProc( VK_F5 ) )

   SET KEY VK_F5 TO Another

   MsgInfo( KeyProc( VK_F5 ) )

return nil

function AddKey( nKey, cProc )

   local nAt

   if Len( aKeys ) == 0 .or. ( nAt := AScan( aKeys, { | a | a[ 1 ] == nKey } ) ) == 0
      AAdd( akeys, { nKey, cProc } )
   else
      aKeys[ nAt ] = { nKey, cProc }
   endif

return nil

function KeyProc( nKey )   

   local nAt := AScan( aKeys, { | a | a[ 1 ] == nKey } )

   if nAt != 0
      return aKeys[ nAt ][ 2 ]
   endif

return ""

function Test()

return nil

function Another()

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Question about SET KEY
Posted: Sat Nov 24, 2007 10:21 PM

Antonio,

Thanks a lot for your help.

I'll try it out ASAP.

Have a good weekend.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion