Page 1 of 1

TDialog bKeyChar and bKeyDown bugs

Posted: Mon Apr 10, 2006 9:20 am
by Enrico Maria Giordano
This is the sample. Try to hit ESC. Is it expected?

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 30 )

    DEFINE DIALOG oDlg

    oDlg:bKeyChar = { || MsgInfo( "bKeyChar" ) }
    oDlg:bKeyDown = { || MsgInfo( "bKeyDown" ) }

    @ 1, 1 GET cVar

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL
This is a possible solution:

Code: Select all

METHOD KeyChar( nKey, nFlags ) CLASS TDialog

   if nKey == VK_ESCAPE
//      if ! Empty( ::bKeyChar )
//         Eval( ::bKeyChar, nKey, nFlags, Self )
//      endif   

...

METHOD KeyDown( nKey, nFlags ) CLASS TDialog

   if nKey == VK_ESCAPE
//      if ! Empty( ::bKeyDown )
//         Eval( ::bKeyDown, nKey, nFlags, Self )
//      endif   
//      if ! Empty( ::bKeyDown )
//         Eval( ::bKeyDown, nKey, nFlags, Self )
//      endif   

...
EMG

Posted: Mon Apr 10, 2006 9:53 am
by Antonio Linares
Enrico,

IMO the bKeyDown and bKeyChar events should be processed even if ESC is pressed. What do you think ?

Posted: Mon Apr 10, 2006 10:03 am
by Enrico Maria Giordano
Decision is yours (of course) but I think this would cause a serious backward compatibility problem.

EMG

Posted: Mon Apr 10, 2006 10:30 am
by Antonio Linares
Enrico,

Yes, you are right :)