Code: Select all | Expand
::xDlg:bKeyDown := { | nKey | ;
iif( nKey == VK_ESCAPE, ::lHitEsc := .T., Nil ), ;
MsgExclamation( iif( ::lHitEsc, "ESC", "other" ) ) }
What I can do about this ?
Code: Select all | Expand
::xDlg:bKeyDown := { | nKey | ;
iif( nKey == VK_ESCAPE, ::lHitEsc := .T., Nil ), ;
MsgExclamation( iif( ::lHitEsc, "ESC", "other" ) ) }
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg
SetDialogEsc( .F. )
DEFINE DIALOG oDlg
oDlg:bKeyDown = { | nKey | MsgInfo( "Key: " + Str( nKey ) ) }
ACTIVATE DIALOG oDlg CENTERED VALID ( ShowCallStack(), .T. )
return nil
SetDialogEsc( .F. ) is working fine with me.SetDialogEsc( .F. ) should allow you to handle it, but it is not. We have to review it:
ACTIVATE DIALOG oDlg VALID ... // logical valueSilvio.Falconi wrote: Tue Mar 11, 2025 10:01 am I would be interested in blocking esc or there must be a function that when a user presses ESc the procedure must check (in case of inserting/modifying records) that the user has not modified the get/combobox/radio controls etc and the procedure must tell the user "do I have to close anyway without saving?", is there a function that does this?
yes of course I have this function but sometimes not run okAntonio Linares wrote: Tue Mar 11, 2025 10:18 amACTIVATE DIALOG oDlg VALID ... // logical valueSilvio.Falconi wrote: Tue Mar 11, 2025 10:01 am I would be interested in blocking esc or there must be a function that when a user presses ESc the procedure must check (in case of inserting/modifying records) that the user has not modified the get/combobox/radio controls etc and the procedure must tell the user "do I have to close anyway without saving?", is there a function that does this?
thats what VALID is implemented for
Code: Select all | Expand
VALID EXit( .f., , , oDlg )
static FUNCTION Exit( lEsc, lAsk, cMsg, oDlg )
DEFAULT lEsc := .f., lAsk := .f., cMsg := ""
if getkeystate( VK_ESCAPE )
Return( lEsc )
endif
//aGet
lAsk := DlgModified( oDlg )
// ? lAsk
If lAsk
If Empty( cMsg )
cMsg := "Do you want to exit this operation?...?"
End
If !MsgNoyes(cMsg,"Confirm Please...")
Return .f.
End
End
return .T.
static function DlgModified( oDlg )
return AScan( oDlg:aControls, { |o| o:IsKindOf( "TGET" ) .and. o:lChanged } ) > 0
Your above example is not working as expected Enabling/Disabling Esc Key functionality.Is the above example working fine for you ? Do you get the VK_ESCAPE MsgInfo() ?
Code: Select all | Expand
VAR lHitESC INIT .F.
Code: Select all | Expand
DO WHILE ! class:lHitEsc .AND. ! :eof()
:MoveNext()
ENDDO
:CloseRecordset()
IF class:lHitEsc
Dialog:Close()
ENDIF
Code: Select all | Expand
function KeyPress( KeyAscii )
IF KeyAscii = ESC
KeyAscii = 0
ENDIF
RETURN
Code: Select all | Expand
dialog:bKeyDown := { | nkey | routine( @nKey ), nKey }
Code: Select all | Expand
::xDlg:bValid := { || iif( GetKeyState( VK_ESCAPE ), ::lHitEsc := .T., Nil ), ::lCanClose }