Page 1 of 1

TDialog:bValid bug

Posted: Tue Mar 14, 2006 10:54 am
by Enrico Maria Giordano
This is the sample. Try to exit with ESC and you will get MsgInfo() two times:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL cVar := SPACE( 20 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET cVar

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

    ACTIVATE DIALOG oDlg;
             ON INIT oDlg:bValid := { || MsgInfo(), .T. };
             CENTER

    RETURN NIL
EMG

Re: TDialog:bValid bug

Posted: Tue Mar 14, 2006 11:22 am
by Enrico Maria Giordano
This is a possible fix (but please double check it):

Code: Select all

METHOD KeyChar( nKey, nFlags ) CLASS TDialog

   if nKey == VK_ESCAPE
      if ::oWnd == nil
//         ::End()  //EMG
      else
         if ::oWnd:ChildLevel( TMdiChild() ) != 0
            ::End()
         else
            if ::oWnd:ChildLevel( TDialog() ) != 0
               ::End()
            #ifdef __HARBOUR__
            elseif Upper( ::oWnd:ClassName() ) == "TMDIFRAME" // To avoid ESC being ignored
               ::End()
            #endif
            else
               return Super:KeyChar( nKey, nFlags )
            endif
         endif
      endif
   else
      return Super:KeyChar( nKey, nFlags )
   endif

return nil
EMG

Posted: Tue Mar 14, 2006 12:38 pm
by Antonio Linares
Enrico,

Thanks! :)

We have been messing lately with ESC and this looks as a side effect.