Page 1 of 1

To Antonio:

PostPosted: Mon Apr 02, 2012 3:25 am
by HunterEC
Antonio:


How can I call a procedure from within a GET via pressing one of the function keys (F1...F12) ? I've tried the following but does not work.
Code: Select all  Expand view
  @ 55,45 GET oGets[5] VAR cCode       OF oDlg SIZE 40,10 PIXEL  PICTURE "@!" ;
                        WHEN EVAL({|| SETKEY(VK_F2, {||  cVar := cCode,  LookUp(@cVar),   ;
                                  cCode := cVar,  oGets[5]:varget(), oGets[5]:refresh()}), .T.})
 


Thank you very much.

Re: To Antonio:

PostPosted: Mon Apr 02, 2012 5:37 am
by Antonio Linares
Pedro,

Tienes un ejemplo en FWH\samples\TestKey.prg :-)

Re: To Antonio:

PostPosted: Mon Apr 02, 2012 6:33 pm
by HunterEC
Antonio:

Thank you for your help. What I'm trying to achieve is to "activate" the SetKey() during the get's WHEN clause and deactivate it in the VALID one. Still I cannot make this work. Any ideas ? Thank you.


Gustavo

Re: To Antonio:

PostPosted: Mon Apr 02, 2012 7:41 pm
by Enrico Maria Giordano
Use oGet:bKeyDown instead.

EMG

Re: To Antonio:

PostPosted: Tue Apr 03, 2012 12:24 am
by HunterEC
Enrico:

Can you provide a small example ?

Thank you.


Gustavo

Re: To Antonio:

PostPosted: Tue Apr 03, 2012 3:15 am
by HunterEC
Antonio:

Can you post an example ? The Testkey.prg addresses a global setkey, what I'm looking is a more specific, defined at the get level. Different gets using different SETKEYS(). All shall be activated when entering the GET field and deactivating it when exiting.Thank you.

Gustavo

Re: To Antonio:

PostPosted: Tue Apr 03, 2012 8:04 am
by Enrico Maria Giordano
HunterEC wrote:Enrico:

Can you provide a small example ?

Thank you.


Gustavo


Code: Select all  Expand view
oGet:bKeyDown = { | nKey | If( nKey = VK_???, MyFunc(), ) }


EMG

Re: To Antonio:

PostPosted: Tue Apr 03, 2012 8:06 am
by Antonio Linares
Pedro,

Here you have it, press F2 on each GET and different actions will be executed:

Code: Select all  Expand view
// Testing Keyboard management

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

   local oDlg
   local oGet1, cFirst := "Hello    "
   local oGet2, cLast := "World    "

   DEFINE DIALOG oDlg TITLE "Function Keys for each GET"

   @ 1, 1 GET oGet1 VAR cFirst SIZE 80, 12 OF oDlg

   oGet1:bKeyDown = { | nKey | If( nKey == VK_F2, MsgInfo( "An action for GET 1" ), ) }

   @ 2, 1 GET oGet2 VAR cLast SIZE 80, 12 OF oDlg

   oGet2:bKeyDown = { | nKey | If( nKey == VK_F2, MsgInfo( "An action for GET 2" ), ) }

   @ 3, 6 BUTTON "Ok" ACTION oDlg:End()

   @ 3, 14 BUTTON "Cancel" ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED
   
return nil

//----------------------------------------------------------------------------//