FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Bug in TControl
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TControl
Posted: Thu Mar 02, 2006 10:29 PM
The ESC key is disabled in the following sample (but it is not the only one) in the March build:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oGet, cVar := SPACE( 30 )

    DEFINE DIALOG oDlg

    @ 1, 1 GET oGet VAR cVar MEMO

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

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


It seems that the cause is a change in TControl:

METHOD KeyDown( nKey, nFlags ) CLASS TControl

   if nKey == VK_ESCAPE
      ::oWnd:KeyDown( nKey, nFlags )
      return 0
   endif


This is the previous working version:

METHOD KeyDown( nKey, nFlags ) CLASS TControl

   if nKey == VK_ESCAPE
      ::oWnd:KeyChar( nKey, nFlags )
      return 0
   endif


EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Bug in TControl
Posted: Fri Mar 03, 2006 12:14 AM
Enrico,

This fix looks as the right one in Class TMultiGet:
   if nKey == VK_ESCAPE  // Windows API already sends it to dialogs!!!
      if ::oWnd:ChildLevel( TDialog() ) != 0 .and. ::oWnd:lModal
         return Super:KeyChar( nKey, nFlags ) // nil
      endif
      ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TControl
Posted: Fri Mar 03, 2006 08:33 AM
It's not enough:

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    DEFINE DIALOG oDlg

    @ 1, 1 LISTBOX oBrw FIELDS SIZE 100, 30

    oBrw:bKeyChar = { || Tone( 440, 1 ) }

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

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


What was the reason why you changed bKeyChar to bKeyDown in TControl:KeyDown() method?

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Bug in TControl
Posted: Fri Mar 03, 2006 09:08 AM

Enrico,

Because it had some wrong side effects

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Bug in TControl
Posted: Fri Mar 03, 2006 09:15 AM

Enrico,

In dialog.prg copy Method KeyChar() to Method KeyDown() and it gets fixed.

Anyhow, we are curious to know why the ESC comes now by KeyDown() instead of KeyChar().

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TControl
Posted: Fri Mar 03, 2006 09:21 AM

Please, can you show the exact fix?

EMG

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Bug in TControl
Posted: Fri Mar 03, 2006 09:23 AM
Enrico,
METHOD KeyDown( nKey, nFlags ) CLASS TDialog

   if nKey == VK_ESCAPE
      if ::oWnd == nil
         ::End()
      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:KeyDown( nKey, nFlags )
            endif
         endif
      endif
   else
      return Super:KeyDown( nKey, nFlags )
   endif

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TControl
Posted: Fri Mar 03, 2006 09:42 AM

It seems to work, thank you. Do I have to leave KeyChar() method in place or do I have to remove it?

EMG

Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Bug in TControl
Posted: Fri Mar 03, 2006 09:57 AM
Antonio Linares wrote:Enrico,

This fix looks as the right one in Class TMultiGet:
   if nKey == VK_ESCAPE  // Windows API already sends it to dialogs!!!
      if ::oWnd:ChildLevel( TDialog() ) != 0 .and. ::oWnd:lModal
         return Super:KeyChar( nKey, nFlags ) // nil
      endif
      ...


This is no more needed.

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Bug in TControl
Posted: Fri Mar 03, 2006 02:05 PM

Enrico,

Thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion