Ok, its working
You have to modify Class TButton Method KeyDown() this way:
- Code: Select all Expand view
METHOD KeyDown( nKey, nFlags ) CLASS TButton
::oWnd:nLastKey := nKey
do case
case nKey == VK_UP .or. nKey == VK_LEFT
if ::bKeyDown != nil
Eval( ::bKeyDown, nkey, nFlags )
else
::oWnd:GoPrevCtrl( ::hWnd )
endif
return 0
case nKey == VK_DOWN .or. nKey == VK_RIGHT
if ::bKeyDown != nil
Eval( ::bKeyDown, nkey, nFlags )
else
::oWnd:GoNextCtrl( ::hWnd )
endif
return 0
case nKey == VK_RETURN
if ::bKeyDown != nil
Eval( ::bKeyDown, nkey, nFlags )
else
PostMessage( ::hWnd, FM_CLICK ) // fire the button's action
endif
return 0
endcase
return Super:KeyDown( nKey, nFlags )
And here you have a working sample:
- Code: Select all Expand view
#include "FiveWin.ch"
function Main()
local oDlg, oBtn1, oBtn2, oBtn3, oBtn4
DEFINE DIALOG oDlg TITLE "Test"
@ 3, 2 BUTTON oBtn1 PROMPT "One" OF oDlg
@ 3, 8 BUTTON oBtn2 PROMPT "Two" OF oDlg
@ 3, 14 BUTTON oBtn3 PROMPT "Three" OF oDlg
@ 3, 20 BUTTON oBtn4 PROMPT "Four" OF oDlg
oBtn1:bKeyDown = { | nKey | MsgInfo( nKey ) }
oBtn1:nDlgCode = DLGC_WANTALLKEYS
oBtn2:bKeyDown = { | nKey | MsgInfo( nKey ) }
oBtn2:nDlgCode = DLGC_WANTALLKEYS
oBtn3:bKeyDown = { | nKey | MsgInfo( nKey ) }
oBtn3:nDlgCode = DLGC_WANTALLKEYS
oBtn4:bKeyDown = { | nKey | MsgInfo( nKey ) }
oBtn4:nDlgCode = DLGC_WANTALLKEYS
ACTIVATE DIALOG oDlg CENTERED
return nil