Trapping key combinations

Trapping key combinations

Postby HunterEC » Mon Apr 20, 2009 11:14 am

How can I trap a key combination like, for example: Control-F2, Control-Y ? I had looked at vkeys.ch with no results. Thank you.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Trapping key combinations

Postby Enrico Maria Giordano » Mon Apr 20, 2009 11:31 am

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet, cVar := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar OF oDlg

    oGet:bKeyDown = { | nKey | Tasti( nKey ) }

    @ 3, 1 BUTTON "&Close" OF oDlg ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


STATIC FUNCTION TASTI( nKey )

    IF nKey = ASC( "H" ) .AND. GETKEYSTATE( VK_CONTROL )
        ? "CTRL-H"
    ENDIF

    IF nKey = ASC( "Z" ) .AND. GETKEYSTATE( VK_CONTROL )
        ? "CTRL-Z"
    ENDIF

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Trapping key combinations

Postby HunterEC » Tue Apr 21, 2009 5:38 am

Thank you Enrico. What I'm trying to do is the following:
Code: Select all  Expand view
SETKEY(K_CTRL_Y, {|| SomeStuff()})
Thanks.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: Trapping key combinations

Postby Enrico Maria Giordano » Tue Apr 21, 2009 8:00 am

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 30 )

    SETKEY( VK_F2, { || If( GetKeyState( VK_CONTROL ), MsgInfo( "CTRL-F2" ), ) } )
    SETKEY( VK_F3, { || If( GetKeyState( VK_SHIFT ), MsgInfo( "SHIFT-F3" ), ) } )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar OF oDlg

    @ 3, 1 BUTTON "&Close" OF oDlg ACTION oDlg:End()

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Trapping key combinations

Postby HunterEC » Tue Apr 21, 2009 2:10 pm

Enrico:

Thank you very much.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 87 guests